434. bitset::to_string() hard to use

Section: 23.9.2.2 [bitset.members] Status: CD1 Submitter: Martin Sebor Opened: 2003-10-15 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [bitset.members].

View all issues with CD1 status.

Discussion:

It has been pointed out a number of times that the bitset to_string() member function template is tedious to use since callers must explicitly specify the entire template argument list (3 arguments). At least two implementations provide a number of overloads of this template to make it easier to use.

Proposed resolution:

In order to allow callers to specify no template arguments at all, just the first one (charT), or the first 2 (charT and traits), in addition to all three template arguments, add the following three overloads to both the interface (declarations only) of the class template bitset as well as to section 23.3.5.2, immediately after p34, the Returns clause of the existing to_string() member function template:

    template <class charT, class traits>
    basic_string<charT, traits, allocator<charT> >
    to_string () const;

    -34.1- Returns: to_string<charT, traits, allocator<charT> >().

    template <class charT>
    basic_string<charT, char_traits<charT>, allocator<charT> >
    to_string () const;

    -34.2- Returns: to_string<charT, char_traits<charT>, allocator<charT> >().

    basic_string<char, char_traits<char>, allocator<char> >
    to_string () const;

    -34.3- Returns: to_string<char, char_traits<char>, allocator<char> >().

[Kona: the LWG agrees that this is an improvement over the status quo. Dietmar thought about an alternative using a proxy object but now believes that the proposed resolution above is the right choice. ]