diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-11-19 11:50:44 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-11-19 11:50:44 +0000 |
commit | fc09e5b6bdee97136601e24eeba7bf10b083a352 (patch) | |
tree | 01cee7a539f7b5f514289603b022800143838636 /libstdc++-v3 | |
parent | cf651ca2e559c5f56f23764f1c90108c52015ea0 (diff) | |
download | gcc-fc09e5b6bdee97136601e24eeba7bf10b083a352.zip gcc-fc09e5b6bdee97136601e24eeba7bf10b083a352.tar.gz gcc-fc09e5b6bdee97136601e24eeba7bf10b083a352.tar.bz2 |
bitset (operator[](size_t) const): Declare constexpr.
2011-11-19 Paolo Carlini <paolo.carlini@oracle.com>
* include/debug/bitset (operator[](size_t) const): Declare constexpr.
* include/profile/bitset: Likewise.
* testsuite/23_containers/bitset/operations/constexpr.cc: Split out
non portable bits to...
* testsuite/23_containers/bitset/operations/constexpr-2.cc: ... here.
From-SVN: r181506
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/bitset | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/bitset | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc | 36 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc | 9 |
5 files changed, 52 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 235aa05..92fe382 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2011-11-19 Paolo Carlini <paolo.carlini@oracle.com> + + * include/debug/bitset (operator[](size_t) const): Declare constexpr. + * include/profile/bitset: Likewise. + * testsuite/23_containers/bitset/operations/constexpr.cc: Split out + non portable bits to... + * testsuite/23_containers/bitset/operations/constexpr-2.cc: ... here. + 2011-11-18 Harti Brandt <hartmut.brandt@dlr.de> PR libstdc++/51209 diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset index f44bbcd..3d865c1 100644 --- a/libstdc++-v3/include/debug/bitset +++ b/libstdc++-v3/include/debug/bitset @@ -51,7 +51,7 @@ namespace __debug public: // In C++0x we rely on normal reference type to preserve the property // of bitset to be use as a literal. - // TODO: Find an other solution. + // TODO: Find another solution. #ifdef __GXX_EXPERIMENTAL_CXX0X__ typedef typename _Base::reference reference; #else @@ -272,11 +272,14 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems - bool + _GLIBCXX_CONSTEXPR bool operator[](size_t __pos) const { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + // TODO: Check in debug-mode too. __glibcxx_check_subscript(__pos); - return _M_base()[__pos]; +#endif + return _Base::operator[](__pos); } using _Base::to_ulong; diff --git a/libstdc++-v3/include/profile/bitset b/libstdc++-v3/include/profile/bitset index a2cba5e..17ee49b 100644 --- a/libstdc++-v3/include/profile/bitset +++ b/libstdc++-v3/include/profile/bitset @@ -232,10 +232,10 @@ namespace __profile // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems - bool + _GLIBCXX_CONSTEXPR bool operator[](size_t __pos) const { - return _M_base()[__pos]; + return _Base::operator[](__pos); } using _Base::to_ulong; diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc b/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc new file mode 100644 index 0000000..14ab8e7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 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> + +int main() +{ + // bitset base type + typedef std::_Base_bitset<6> bitset_base; + constexpr bitset_base base = bitset_base(); + + constexpr auto r1 __attribute__((unused)) = base._M_getword(2); + // constexpr auto r2 = base._M_getdata(); // error, pointer to this + auto r2 __attribute__((unused)) = base._M_getdata(); + constexpr auto r3 __attribute__((unused)) = base._M_hiword(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc b/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc index fc171c8..384f01a 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc +++ b/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc @@ -22,15 +22,6 @@ int main() { - // bitset base type - typedef std::_Base_bitset<6> bitset_base; - constexpr bitset_base base = bitset_base(); - - constexpr auto r1 __attribute__((unused)) = base._M_getword(2); - // constexpr auto r2 = base._M_getdata(); // error, pointer to this - auto r2 __attribute__((unused)) = base._M_getdata(); - constexpr auto r3 __attribute__((unused)) = base._M_hiword(); - // bitset operators typedef std::bitset<6> bitset_type; constexpr bitset_type a = bitset_type(); |