This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

1325. bitset

Section: 22.9.2.2 [bitset.cons] Status: C++11 Submitter: Christopher Jefferson Opened: 2010-03-07 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [bitset.cons].

View all issues with C++11 status.

Discussion:

As mentioned on the boost mailing list:

The following code, valid in C++03, is broken in C++0x due to ambiguity between the "unsigned long long" and "char*" constructors.

#include <bitset>
std::bitset<10> b(0);

[ The proposed resolution has been reviewed by Stephan T. Lavavej. ]

[ Post-Rapperswil ]

The proposed resolution has two problems:

Moved to Tentatively Ready with revised wording provided by Alberto Ganesh Babati after 5 positive votes on c++std-lib.

[ Adopted at 2010-11 Batavia ]

Proposed resolution:

  1. In the synopsis of header <bitset> in 22.9.2 [template.bitset]/1, replace the fourth bitset constructor:
    explicit bitset(const char *str);
    template <class charT>
      explicit bitset(
        const charT *str,
        typename basic_string<charT>::size_type n = basic_string<charT>::npos,
        charT zero = charT('0'), charT one = charT('1'));
    
  2. In 22.9.2.2 [bitset.cons]/8:
    explicit bitset(const char *str);
    template <class charT>
    explicit
    bitset(const charT *str,
           typename basic_string<charT>::size_type n = basic_string<charT>::npos,
           charT zero = charT('0'), charT one = charT('1'));
    

    Effects: Constructs an object of class bitset<N> as if by bitset(string(str)).

    
    bitset(
      n == basic_string<charT>::npos
        ? basic_string<charT>(str)
        : basic_string<charT>(str, n),
      0, n, zero, one)