diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2009-12-29 12:24:36 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2009-12-29 12:24:36 +0000 |
commit | 700d2899472c55c8bf83db69056f45bbd2fb7b17 (patch) | |
tree | 695b08a8b30f039735cf8d1520196297d489fbca /libstdc++-v3 | |
parent | 497d63a44eb2291fd2bea10f5312b4d1a3a63dee (diff) | |
download | gcc-700d2899472c55c8bf83db69056f45bbd2fb7b17.zip gcc-700d2899472c55c8bf83db69056f45bbd2fb7b17.tar.gz gcc-700d2899472c55c8bf83db69056f45bbd2fb7b17.tar.bz2 |
bitset (bitset<>::to_ullong, [...]): Add.
2009-12-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/bitset (bitset<>::to_ullong, _M_do_to_ullong): Add.
(_Base_bitset<>::_M_do_to_ullong): Add.
* include/debug/bitset (bitset<>): Add using _Base::to_ullong.
* include/profile/bitset (bitset<>): Likewise.
* testsuite/23_containers/bitset/to_ullong/1.cc: New.
From-SVN: r155504
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/bitset | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/bitset | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/std/bitset | 40 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc | 44 |
5 files changed, 98 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c20bc0d..22c8a63 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2009-12-29 Paolo Carlini <paolo.carlini@oracle.com> + + * include/std/bitset (bitset<>::to_ullong, _M_do_to_ullong): Add. + (_Base_bitset<>::_M_do_to_ullong): Add. + * include/debug/bitset (bitset<>): Add using _Base::to_ullong. + * include/profile/bitset (bitset<>): Likewise. + * testsuite/23_containers/bitset/to_ullong/1.cc: New. + 2009-12-28 Paolo Carlini <paolo.carlini@oracle.com> * include/debug/bitset (bitset<>::bitset(const char*)): Add. diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset index 5e5f35d..734bf22 100644 --- a/libstdc++-v3/include/debug/bitset +++ b/libstdc++-v3/include/debug/bitset @@ -251,6 +251,9 @@ namespace __debug } using _Base::to_ulong; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + using _Base::to_ullong; +#endif template <typename _CharT, typename _Traits, typename _Alloc> std::basic_string<_CharT, _Traits, _Alloc> diff --git a/libstdc++-v3/include/profile/bitset b/libstdc++-v3/include/profile/bitset index 1d8ad9f..7df8d88 100644 --- a/libstdc++-v3/include/profile/bitset +++ b/libstdc++-v3/include/profile/bitset @@ -226,6 +226,9 @@ namespace __profile } using _Base::to_ulong; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + using _Base::to_ullong; +#endif template <typename _CharT, typename _Traits, typename _Alloc> std::basic_string<_CharT, _Traits, _Alloc> diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index 3aee5c0..7884355 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -199,6 +199,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) unsigned long _M_do_to_ulong() const; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + unsigned long long + _M_do_to_ullong() const; +#endif + // find first "on" bit size_t _M_do_find_first(size_t __not_found) const; @@ -272,6 +277,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) return _M_w[0]; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<size_t _Nw> + unsigned long long + _Base_bitset<_Nw>::_M_do_to_ullong() const + { + const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long); + for (size_t __i = 1 + __dw; __i < _Nw; ++__i) + if (_M_w[__i]) + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ullong")); + + if (__dw) + return _M_w[0] + (static_cast<unsigned long long>(_M_w[1]) + << _GLIBCXX_BITSET_BITS_PER_WORD); + return _M_w[0]; + } +#endif + template<size_t _Nw> size_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const @@ -425,6 +447,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_do_to_ulong() const { return _M_w; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + unsigned long long + _M_do_to_ullong() const + { return _M_w; } +#endif + size_t _M_do_find_first(size_t __not_found) const { @@ -555,6 +583,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_do_to_ulong() const { return 0; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + unsigned long long + _M_do_to_ullong() const + { return 0; } +#endif + // Normally "not found" is the size, but that could also be // misinterpreted as an index in this corner case. Oh well. size_t @@ -1039,6 +1073,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) to_ulong() const { return this->_M_do_to_ulong(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + unsigned long long + to_ullong() const + { return this->_M_do_to_ullong(); } +#endif + /** * @brief Returns a character interpretation of the %bitset. * @return The string equivalent of the bits. diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc b/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc new file mode 100644 index 0000000..2a3b886 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-12-29 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::bitset<0> bs0; + VERIFY( bs0.to_ullong() == 0 ); + + std::bitset<64> bs1("11010111"); + VERIFY( bs1.to_ullong() == 215 ); + + std::bitset<64> bs2("10110100100010000100000101111111" + "01111110011111110001110001100011"); + VERIFY( bs2.to_ullong() == 13008719539498589283ULL ); +} + +int main() +{ + test01(); + return 0; +} |