summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-28 09:57:57 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-28 09:57:57 +0000
commit5f96c99844e6f2823a05b34a2ad1aa0adb67dbe7 (patch)
tree981b50da28009ea41eebe9fe7641784fcbf5f76d /libstdc++-v3/include
parentf8edf7c28c678558f5d9014c15a5075f86d67a40 (diff)
downloadppe42-gcc-5f96c99844e6f2823a05b34a2ad1aa0adb67dbe7.tar.gz
ppe42-gcc-5f96c99844e6f2823a05b34a2ad1aa0adb67dbe7.zip
2005-12-28 Paolo Carlini <pcarlini@suse.de>
* include/std/std_bitset.h (bitset<>::_M_copy_from_string, bitset<>::_M_copy_to_string, bitset<>::operator>>): Reverse loop. * testsuite/25_algorithms/heap/heap.cc (test01): Always enable complexity checks. * testsuite/18_support/numeric_limits/specialization.cc: Avoid unused parameter warning. * testsuite/18_support/numeric_limits/traps.cc: Acoid unused variable warning. * testsuite/ext/malloc_allocator/deallocate_global.cc: Fix format string. * testsuite/ext/malloc_allocator/deallocate_local.cc: Likewise. * testsuite/ext/array_allocator/2.cc: Remove unused variable. * testsuite/tr1/3_function_objects/mem_fn.cc: Avoid unused variable warnings. * testsuite/tr1/6_containers/unordered/instantiate/set.cc: Just instantiate. * testsuite/tr1/6_containers/unordered/instantiate/map.cc: Likewise. * testsuite/tr1/6_containers/unordered/instantiate/hash.cc: Likewise. * testsuite/tr1/6_containers/unordered/instantiate/multiset.cc: Likewise. * testsuite/tr1/6_containers/unordered/instantiate/multimap.cc: Likewise. * testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc: Avoid unused variable warnings. * testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc: Likewise. * testsuite/thread/18185.cc: Likewise. * testsuite/27_io/ios_base/storage/11584.cc: Likewise; avoid comparison between signed and unsigned warning. * testsuite/27_io/types/1.cc: Avoid unused variable warnings. * testsuite/testsuite_allocator.h (check_new): Likewise. (check_deallocate_null): Adjust return type. * testsuite/testsuite_hooks.h (bitmask_operators): Avoid unused variable warnings. * testsuite/21_strings/c_strings/wchar_t/24559.cc: Avoid unused variable warning. 2005-12-28 Chris Jefferson <chris@bubblescope.net> * include/std/std_bitset.h (bitset<0>::set, bitset<0>::reset, bitset<0>::flip, bitset<0>::test): Add inline specializations for bitset<0>. * testsuite/tr1/6_containers/unordered/insert/multiset_range.cc (test01): Add static cast. * testsuite/tr1/6_containers/unordered/insert/set_range.cc (test01): Likewise. * testsuite/testsuite_hooks.h (operator==(NonDefaultConstructible, NonDefaultConstructible), operator<(NonDefaultConstructible, NonDefaultConstrictible)): Avoid unused parameter warning. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109103 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/std/std_bitset.h61
1 files changed, 50 insertions, 11 deletions
diff --git a/libstdc++-v3/include/std/std_bitset.h b/libstdc++-v3/include/std/std_bitset.h
index c1cfadad7bd..ad47238ed62 100644
--- a/libstdc++-v3/include/std/std_bitset.h
+++ b/libstdc++-v3/include/std/std_bitset.h
@@ -1144,19 +1144,20 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
template<size_t _Nb>
template<class _CharT, class _Traits, class _Alloc>
void
- bitset<_Nb>::_M_copy_from_string(const std::basic_string<_CharT, _Traits,
- _Alloc>& __s, size_t __pos, size_t __n)
+ bitset<_Nb>::
+ _M_copy_from_string(const std::basic_string<_CharT, _Traits,
+ _Alloc>& __s, size_t __pos, size_t __n)
{
reset();
const size_t __nbits = std::min(_Nb, std::min(__n, __s.size() - __pos));
- for (size_t __i = 0; __i < __nbits; ++__i)
+ for (size_t __i = __nbits; __i > 0; --__i)
{
- switch(__s[__pos + __nbits - __i - 1])
+ switch(__s[__pos + __nbits - __i])
{
case '0':
break;
case '1':
- set(__i);
+ set(__i - 1);
break;
default:
__throw_invalid_argument(__N("bitset::_M_copy_from_string"));
@@ -1167,13 +1168,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
template<size_t _Nb>
template<class _CharT, class _Traits, class _Alloc>
void
- bitset<_Nb>::_M_copy_to_string(std::basic_string<_CharT, _Traits,
- _Alloc>& __s) const
+ bitset<_Nb>::
+ _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s) const
{
__s.assign(_Nb, '0');
- for (size_t __i = 0; __i < _Nb; ++__i)
- if (_Unchecked_test(__i))
- __s[_Nb - 1 - __i] = '1';
+ for (size_t __i = _Nb; __i > 0; --__i)
+ if (_Unchecked_test(__i - 1))
+ __s[_Nb - __i] = '1';
}
// 23.3.5.3 bitset operations:
@@ -1242,7 +1243,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
// 303. Bitset input operator underspecified
const char_type __zero = __is.widen('0');
const char_type __one = __is.widen('1');
- for (size_t __i = 0; __i < _Nb; ++__i)
+ for (size_t __i = _Nb; __i > 0; --__i)
{
static typename _Traits::int_type __eof = _Traits::eof();
@@ -1290,6 +1291,44 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
__x._M_copy_to_string(__tmp);
return __os << __tmp;
}
+
+ // Specializations for zero-sized bitsets, to avoid "unsigned comparison
+ // with zero" warnings.
+ template<>
+ inline bitset<0>&
+ bitset<0>::
+ set(size_t, bool)
+ {
+ __throw_out_of_range(__N("bitset::set"));
+ return *this;
+ }
+
+ template<>
+ inline bitset<0>&
+ bitset<0>::
+ reset(size_t)
+ {
+ __throw_out_of_range(__N("bitset::reset"));
+ return *this;
+ }
+
+ template<>
+ inline bitset<0>&
+ bitset<0>::
+ flip(size_t)
+ {
+ __throw_out_of_range(__N("bitset::flip"));
+ return *this;
+ }
+
+ template<>
+ inline bool
+ bitset<0>::
+ test(size_t) const
+ {
+ __throw_out_of_range(__N("bitset::test"));
+ return false;
+ }
//@}
_GLIBCXX_END_NESTED_NAMESPACE
OpenPOWER on IntegriCloud