Guillaume Munch wrote:

> Dear all,
> 
> Here's a few patches proposing to improve the definitions in
> support/strfwd.h, results of my experiments.
> 
> 1. Define docstring using the Unicode strings from C++11 (with
> char_type=char32_t). This allows us to write docstrings directly with
> the syntax U"". By extension this is necessary to have Unicode
> translation strings as discussed before. This is not the final version
> of the patch however because there is one big disappointment: the C++11
> standard does not require several facets (including ctype<char32_t>)
> that are necessary to use stringstreams of char32_t. So these need to be
> defined by hand.

Which is not a problem IMHO. Our own facets work, and the implementation is 
confined to one file which nobody needs to look at (unless he wants to).

> I reused ones that are currently in
> support/docstring.cpp written about 10yrs ago but I wonder whether one
> cannot just copy ones for wchar_t from libstdc++ or libc++ (while being
> no expert on this matter). Help/opinions on this problem are welcome.

I would not try that. First you would need to be sure about the licensing 
(the difference to the stuff in 3rdparty is that it would not be optional, 
and the libstdc++ license changed from the time when we included the old 
stuff in strfwd.h), then you would need to check for compiler specific 
parts.

> 3. This patch addresses the issue of std::basic_string being
> thread-unsafe on gcc < 5.1 by noticing that the thread-safe
> implementation from gcc 5.1 is available for gcc >= 4.6 in
> <ext/vstring.h>. I think that this works well.

AFAIK we do currently not need string literals in combination with 
trivstring, so I do not see an advantage of replacing it with something 
else, especially looking at 4. IMHO we should simply keep trivstring until 
we can require gcc 5.1.

> 4. This patch is just to show what it would involve to completely get
> rid of trivstring.h in favour of <ext/vstring.h>. Given the result I do
> not recommend its inclusion because it adds a lot of noise with the
> explicit conversions.

They are not only noise, going from string to char * to string again can be 
a lossy conversion. We _should_ not use embededded 0 characters in strings, 
but I would not bet on that.

> The patches can be applied independently. (For 3. this requires a small
> adaptation but docstring can be made thread-safe independently of
> whether Unicode strings are used.)

To me the most important part (the first patch) looks very promising. Very 
nice work! Is there anything besides the facets that you think is not ready? 
The only thing I would do differently is the replacement of empty_string() 
and empty_docstring(): Those were introduced to avoid including <string>. 
Since <string> is now required, it would be better to initialize the default 
arguments with docstring() or std::string(). And in a second step we should 
get rid of strfwd.h completely, the name would be wrong for all compilers 
then.


Georg


Reply via email to