Boost logo

Boost :

Subject: Re: [boost] [spirit2] How to get encoding-specific parsers by character type
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-06-11 17:13:58

On 06/11/2010 12:35 PM, Hartmut Kaiser wrote:
>> I was wondering if it was possible to get encoding-specific parsers by
>> character type? Something like that:
>> template< typename CharT>
>> struct encoding_specific
>> {
>> ...
>> };
>> typedef encoding_specific< char> narrow;
>> narrow::char_; // equivalent to spirit::standard::char_
>> typedef encoding_specific< wchar_t> wide;
>> wide::char_; // equivalent to spirit::standard_wide::char_
>> This would help a lot in generic programming, when the character type is
>> not known. Is there a tool like that already? If not, could it be added?
> There isn't anything like that. The reason is that usually you want to
> specify a character set in addition to the character type to use. So the
> solution above is nothing I would like to see in Spirit, even if it might be
> sufficient for your particular case. OTOH, if it is sufficient for you why
> don't you just add it inside your namespace and be done?

Well, I did so. It just so happens that I find myself replicating that
code in different places.

I'm not very familiar with the standard specs on the new character types
but isn't there a strong relationship between the character type and
encoding? Can't we be sure that e.g. char16_t is UTF-16, char is the
standard narrow and wchar_t is the standard wide encoding?

Boost list run by bdawes at, gregod at, cpdaniel at, john at