|
Boost : |
Subject: Re: [boost] [metaparse] performance comparisons?
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2015-06-07 06:40:31
07.06.2015 12:07, Roland Bock:
> However, this is limited in the way that the type cannot be based on a
> literal outside a struct/class. There also is a macro that can be
> employed to create such types, e.g:
>
> SQLPP_ALIAS_PROVIDER(hello);
By the way, I saw sqlpp11 earlier, and I think that alias/field provider
is a useful meta-programming tool on it's own.
https://github.com/rbock/sqlpp11/blob/master/include/sqlpp11/alias_provider.h#L33-L48
For example it can be used in transformation of vector of structs into
structs of vectors - such macro would provide names for fields in
synthesized struct of references.
Perhaps it could be embedded by default into BOOST_FUSION_DEFINE_STRUCT
and others.
Also I think following template intrinsic can be useful addition to C++ ISO:
template<char...> struct names_provider;
Which would be automatically specialized by compiler on usage, for
example something like:
template<>
struct names_provider<'f', 'o', 'o'>
{
template<typename T>
struct field
{
T foo;
};
template<typename F>
struct method
{
template<typename ...Ts>
auto foo(Ts... args)
{
return F{}(args...);
}
};
// ...
};
With help of such intrinsic it is possible to parse string with some
EDSL at compile time, and based only on this generate all required
structures defined by language embedded in string.
Best Regards,
Evgeny Panasyuk
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk