Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2005-06-22 07:30:24

Tag types:

The kinds of a type to be synthesised and complex classification queries are
described by *tag* types.

A tag encapsulates one or more aspects of the kind of type (see reference).

Tags which only encapsulate a single aspect are called *aspect tags* in the
following text.
These can be used to query, whether a type's kind reflects this aspect:

      is_function_type< T, pointer >
      is_function_type< T, variadic >

Aspects can be *abstract* : In this case several non-abstract possibilities of
the same aspect are matched for querying:

      is_function_type< T, unbound >

    is equivalent to:

      mpl::or_< is_function_type< T, undecorated>
              , is_function_type< T, pointer>
              , is_function_type< T, reference> >

When an aspect tag is used to specify the kind of type to be synthesized, only a
single aspect can be specified explicitly:

      function_type< mpl::single_view<void>, variadic >::type is void(...)
      function_type< void(), pointer >::type is void(*)()

Abstract tag aspects are concretized (see refernce) when used for type synthesis:

      function_type<void(my_class::*)(), unbound>::type is void()

When a tag is taken from a type, the resulting tag explicitly describes all
aspects and none of them have abstract state:

      kind_of< void() > describes all aspects: undecorated, non-variadic, ...

When classifying or synthesising types there are situations where it is
neccessary to describe more than one aspect. Therefore tags can be combined.

E.g. for synthesising a both variadic and pointer-decorated function:

      function_type< mpl::vector<int,int>, tag<pointer,variadic> >::type

In classification context all aspects in the query tag must match:

      is_function_type< void(...), tag<unbound,variadic> >::value == true

      is_function_type< void(my_class::*)(...), tag<unbound,variadic> >::value
        == false

When the 'tag' metafunction is used to combine tags, which describe different
possibiltiies of the same aspects, the right hand side tag's aspect is used --
it *overrides* the aspect:

      tag<unbound,reference>'s decoration aspect is 'reference'
      tag<reference,undecorated>'s decoration aspect is 'undecorated'
      tag<unbound,reference,unbound>'s decoration aspect is 'unbound'

Tag combination occurs either explicitly by using the 'tag' metafunction or
implicitly when using 'function_type' with an optionally decorated function type
or a specialization of 'signature' as its first template argument:

     function_type<void __cdecl(my_class::*)(),tag<undecorated,unspecified_call> >

overrides the decoration and calling convention aspect of the
'void __cdecl(my_class*)()'s kind and thus returns 'void(my_class&)'.

Aspect tag reference (some more detail is still missing, here):

     // - decoration aspect
     typedef /.../ unspecified_decoration; // (*) (default)
     typedef /.../ unbound; // (*) (matches the next three)
     typedef /.../ undecorated;
     typedef /.../ pointer;
     typedef /.../ reference;
     typedef /.../ member_pointer;
     // (*) abstract - same as 'undecorated' when used for synthesis

     // - variadic aspect
     typedef /.../ unspecified_variadic; // (*) (default)
     typedef /.../ non_variadic;
     typedef /.../ variadic;
     // (*) abstract - same as 'non_variadic' when used for synthesis

     // - const aspect
     typedef /.../ unspecified_constness; // (*) (default)
     typedef /.../ const_;
     typedef /.../ non_const;
     // (*) abstract - same qualfication as the class type when used for synthesis

     // - volatile aspect
     typedef /.../ unspecified_volatility; // (*) (default)
     typedef /.../ volatile_;
     typedef /.../ non_volatile;
     // (*) abstract - same qualfication as the class type when used for synthesis

     // Calling convention aspect
     typedef /.../ unspecified_call; // (*) (default)
     typedef /.../ cdecl, stdcall, etc. (depends on configuration)
     // (*) abstract - uses the default calling convention when used for synthesis

Boost list run by bdawes at, gregod at, cpdaniel at, john at