...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Boost.FunctionTypes uses tag types to encode properties that are not types per se, such as calling convention or whether a function is variadic or cv- qualified.
These tags can be used to determine whether one property of a type has a particular value.
is_function<int(...), variadic>::value // == true is_function<int() , variadic>::value // == false
A compound property tag describes a combination of possible values of different
properties. The type components<F>
, where F
is a callable builtin type, is a compound property tag that describes F
.
The tag
class template can be used to combine property tags.
tag<non_const,default_cc> // combination of two properties
When several values for the same property are specified in tag
's
argument list, only the rightmost one is used; others are ignored.
tag<components<F>, default_cc> // overrides F's calling convention property
When compound property tag is specified to analyse a type, all of its component properties must match.
is_member_function_pointer< F, tag<const_qualified,default_cc> >::value // true for // F = void(a_class::*)() const // false for // F = void(a_class::*)() // F = void(__fastcall a_class::*)() const
Default values are selected for properties not specified by the tag in the context of type synthesis.
// given S = mpl::vector<int,a_class const &> member_function_pointer<S>::type // is int (a_class::*)() const // note: the cv-qualification is picked based on the class type, // a nonvariadic signature and the default calling convention // are used member_function_pointer<S,non_const>::type // is int (a_class::*)() // no const qualification, as explicitly specified by the tag type