Subject: Re: [boost] [metaparse] performance comparisons?
From: Roland Bock (rbock_at_[hidden])
Date: 2015-06-07 15:30:13


Hi Abel,

On 2015-06-07 20:41, Abel Sinkovics wrote:
> Hi Roland,
>
> On 2015-06-07 11:07, Roland Bock wrote:
>>
>> FWIW, sqlpp11 also uses char packs to represent and being able to
>> compare strings at runtime. It is used like this (full example is
>> attached, requires c++14, won't work with current MSVC-2015RC):
>>
>> struct A
>> {
>> static constexpr const char _literal[] = "delta";
>> using name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
>> };
> It looks like you managed to use a char array as a template argument.
> I don't know how sqlpp uses these strings, however, if the same could
> be achieved in Metaparse, I'd definitely try carrying the char array
> reference/pointer around and write "smart" getter functions (front,
> pop_front, equal_to etc) around it and check if it really makes things
> faster and lower the memory consumption - I'd expect it to do so.
In sqlpp11 the char_sequence contains a static function that returns a
const char*. Storing a reference/pointer to the "original" array does
not seem to work in all cases (after being handed through some template
aliases, they seem to break).

The char_sequence is used to compare names of objects representing
columns, tables and the like. Instead of comparing actual strings at
compile time, the library can compare types.

Also, the char_sequence is used in serializing expressions (this is
where that static function comes into play).
>
>> Thus, while I assume that it is faster than what happens inside the
>> MPLLIBS_STRING (haven't measured it), its use is more limited, too.
> The main limit here (from Metaparse's perspective) is that you need to
> define the string (separately) before you can use it.
Right. With the input from Evgeny I was able to change that to the
extent, that I can now use them in-place as function arguments (but not
as template parameters or type declarations like yours).

Hmm. This might lead to an alternative syntax, btw. Instead of

using X = typename exp_parser3::apply<MPLLIBS_STRING("11 ")>::type;

we could call

auto x = exp_parser3::apply(MPLLIBS_STRING("11 "));

Not sure if and how this could be useful in the context of your library.

Best,

Roland