Mixins For C++ - Roland Bock
Mixins For C++ - Roland Bock
2014-09-08
We have
Single inheritance
Multiple inheritance
Variadic inheritance
And we could use CRTP with all of these.
template<typename... Columns>
auto select(Columns... columns)
-> decltype(blank_select_t<void>().columns(columns...))
{
return blank_select_t<void>().columns(columns...);
}
Examples
template<typename T, name x>
struct field
{
using type = T;
using name = x;
using another_name = 8 foo 8 ;
// methods
using mixin expression_operators<value_type>;
using mixin result_provider<Policies>::_result_methods;
using mixin Policies::_methods...;
// data members
policies::member_type policies::member_name...;
};
Mixin
The body of the mixin is copied to its destination
Template parameters are applied before copying
Overloads or name clashes are handled as if the code of the mixin
had been written at its destination
Name Literals
Name literals can be used wherever ordinary names can be used
Name literals can have a name of their own
Name literals can be used as template parameters
Name literals can be used as string literals (not vice versa)