template<typename... FEATURES>
struct density::feature_list< FEATURES >
Type-list class template that can be used to specify which features a runtime_type captures from the target type.
Each type in the template arguments is either:
- a type satisfying the requirements of TypeFeature, like a built-in type feature (f_size, f_alignment, f_default_construct, f_copy_construct, f_move_construct, f_destroy, f_hash, f_rtti, f_equal, f_less, f_istream, f_ostream), or a user defined type feature.
- a nested feature_list
- the special tag type f_none
using FewFeatures = feature_list<f_size, f_alignment>;
using MoreFeatures = feature_list<FewFeatures, f_default_construct, f_copy_construct, f_move_construct, f_destroy>;
using ManyFeatures = feature_list<MoreFeatures, f_equal, f_less, f_hash>;
feature_list provides a template alias to an std::tuple. An instance of this tuple is a pseudo-vtable associated to the target type.
static_assert(std::is_same<
FewFeatures::tuple_type,
std::tuple<f_size, f_alignment>>::value, "");
For the composition of the tuple:
- nested features are flatened
- duplicates are removed (only the first occurrence of a feature is considered)
- any occurrence of the pseudo-feature f_none is stripped out
static_assert(std::is_same<
ManyFeatures::tuple_type, std::tuple<
f_size, f_alignment,
f_default_construct, f_copy_construct, f_move_construct, f_destroy,
f_equal, f_less, f_hash
>>::value, "");
Two feature lists are equivalent if they prduce the same feature tuple:
using Features1 = feature_list<f_size, f_alignment, f_copy_construct>;
using Features2 = feature_list< feature_list<f_size>,
feature_list<f_alignment, f_copy_construct>>;
using Features3 = feature_list<
feature_list<f_size, f_none>, feature_list<feature_list<f_none>>,
feature_list<f_size, f_alignment, f_copy_construct, f_none, f_copy_construct, f_size>>;
static_assert(std::is_same<Features1::tuple_type, Features2::tuple_type>::value, "");
static_assert(std::is_same<Features2::tuple_type, Features3::tuple_type>::value, "");