Topic: Proposed Resolution: Defect Report 2226 - wstring_convert methods do not take allocator instance


Author: Glen Fernandes<glen.fernandes@googlemail.com>
Date: Tue, 22 Jan 2013 10:55:28 CST
Raw View
Proposed resolution to Defect Report 2226:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2226

1. In [conversions.string] 22.3.3.2.2/2 and /6 "Class template wstring_convert synopsis" change the overloads of the member function from_bytes() so that all four overloads take an additional parameter which is an instance of Wide_alloc:

     wide_string from_bytes(char byte,<ins>const Wide_alloc&  alloc = Wide_alloc()</ins>);
     wide_string from_bytes(const char *ptr,<ins>const Wide_alloc&  alloc = Wide_alloc()</ins>);
     wide_string from_bytes(const byte_string&  str,<ins>const Wide_alloc&  alloc = Wide_alloc()</ins>);
     wide_string from_bytes(const char *first, const char *last,<ins>const Wide_alloc&  alloc = Wide_alloc()</ins>);

In /6 specify that this Wide_alloc allocator parameter is used to construct the wide_string object returned from the function.

2. In [conversions.string] 22.3.3.2.2/2 and /11 "Class template wstring_convert synopsis" change the overloads of the member function to_bytes() so that all four overloads take an additional parameter which is an instance of Byte_alloc:

byte_string to_bytes(Elem wchar,<ins>const Byte_alloc&  alloc = Byte_alloc()</ins>);
byte_string to_bytes(const Elem *wptr,<ins>const Byte_alloc&  alloc = Byte_alloc()</ins>);
byte_string to_bytes(const wide_string&  wstr,<ins>const Byte_alloc&  alloc = Byte_alloc()</ins>);
byte_string to_bytes(const Elem *first, const Elem *last,<ins>const Byte_alloc&  alloc = Byte_alloc()</ins>);

In /11 specify that this Byte_alloc allocator parameter is used to construct the byte_string object returned from the function.

Glen Fernandes

On Friday, December 14, 2012 9:10:18 AM UTC-8, Glen Fernandes wrote:
>  The wstring_convert class template, described in 22.3.3.2.2 [conversions.string], does not support custom stateful allocators. It only supports custom stateless allocators.
>
>  The to_bytes member function returns basic_string<char, char_traits<char>, Byte_alloc>   but it does not take an instance of Byte_alloc to pass to the constructor of the basic_string.
>
>  Similarly the from_bytes member function returns basic_string<Elem, char_traits<Elem>, Wide_alloc>   but it does not take an instance of Wide_alloc to pass to the constructor of the basic_string.
>
>  This makes these two member functions and the wstring_convert class template not usable when Wide_alloc or Byte_alloc are stateful allocators.
>
>  Glen Fernandes
>


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]