summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-11 22:32:01 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-11 22:32:01 +0000
commit0f0ce5ae5016cde1b60d7dc9b76d76497df816a8 (patch)
tree18bf2f094ffa4469352b648b932b7f456d33a389 /libstdc++-v3/include
parentcd6d4e14e5339aad3280ee24b26af77b23f4599d (diff)
downloadgcc-0f0ce5ae5016cde1b60d7dc9b76d76497df816a8.tar.gz
2010-10-11 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/23_containers/bitset/cons/2.cc: Tweak. 2010-10-11 Paolo Carlini <paolo.carlini@oracle.com> * include/std/bitset (bitset<>::bitset(const _CharT*, typename std::basic_string<>::size_type, _CharT, _CharT)): Implement new proposed resolution for DR 1325. * include/debug/bitset: Likewise. * include/profile/bitset: Likewise. * testsuite/23_containers/bitset/cons/dr1325-1.cc: New. * testsuite/23_containers/bitset/cons/dr1325-2.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/debug/bitset9
-rw-r--r--libstdc++-v3/include/profile/bitset9
-rw-r--r--libstdc++-v3/include/std/bitset37
3 files changed, 37 insertions, 18 deletions
diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset
index 017c9e020dd..739dcfd38f1 100644
--- a/libstdc++-v3/include/debug/bitset
+++ b/libstdc++-v3/include/debug/bitset
@@ -150,8 +150,13 @@ namespace __debug
bitset(const _Base& __x) : _Base(__x), _Safe_base() { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- explicit
- bitset(const char* __str) : _Base(__str) { }
+ template<typename _CharT>
+ explicit
+ bitset(const _CharT* __str,
+ typename std::basic_string<_CharT>::size_type __n
+ = std::basic_string<_CharT>::npos,
+ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
+ : _Base(__str, __n, __zero, __one) { }
#endif
// 23.3.5.2 bitset operations:
diff --git a/libstdc++-v3/include/profile/bitset b/libstdc++-v3/include/profile/bitset
index 79175244bed..b8b1e65f9e5 100644
--- a/libstdc++-v3/include/profile/bitset
+++ b/libstdc++-v3/include/profile/bitset
@@ -127,8 +127,13 @@ namespace __profile
bitset(const _Base& __x) : _Base(__x) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- explicit
- bitset(const char* __str) : _Base(__str) { }
+ template<typename _CharT>
+ explicit
+ bitset(const _CharT* __str,
+ typename std::basic_string<_CharT>::size_type __n
+ = std::basic_string<_CharT>::npos,
+ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
+ : _Base(__str, __n, __zero, __one) { }
#endif
// 23.3.5.2 bitset operations:
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index d263fae645a..1c71c4fb969 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -870,22 +870,31 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
- * @brief Construct from a string.
- * @param str A string of @a 0 and @a 1 characters.
+ * @brief Construct from a character %array.
+ * @param str An %array of characters @a zero and @a one.
+ * @param n The number of characters to use.
+ * @param zero The character corresponding to the value 0.
+ * @param one The character corresponding to the value 1.
* @throw std::invalid_argument If a character appears in the string
- * which is neither @a 0 nor @a 1.
+ * which is neither @a zero nor @a one.
*/
- explicit
- bitset(const char* __str)
- : _Base()
- {
- if (!__str)
- __throw_logic_error(__N("bitset::bitset(const char*)"));
-
- const size_t __len = __builtin_strlen(__str);
- _M_copy_from_ptr<char, std::char_traits<char>>(__str, __len, 0,
- __len, '0', '1');
- }
+ template<typename _CharT>
+ explicit
+ bitset(const _CharT* __str,
+ typename std::basic_string<_CharT>::size_type __n
+ = std::basic_string<_CharT>::npos,
+ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
+ : _Base()
+ {
+ if (!__str)
+ __throw_logic_error(__N("bitset::bitset(const _CharT*, ...)"));
+
+ if (__n == std::basic_string<_CharT>::npos)
+ __n = std::char_traits<_CharT>::length(__str);
+ _M_copy_from_ptr<_CharT, std::char_traits<_CharT>>(__str, __n, 0,
+ __n, __zero,
+ __one);
+ }
#endif
// 23.3.5.2 bitset operations: