Return-value type used to implement overload selection. More...
#include <senf/Utils/mpl.hh>
Public Attributes | |
char | _ [SENF_MPL_RV_ALIGNMENT][n+1] |
Return-value type used to implement overload selection.
The senf::mpl::rv type is used together with SENF_MPL_RV() to select template specializations based on a set of overloads:
The selection is always based on two components: A selector class specialized for each of the possible choices and an overloaded function (only signatures, no implementation needed) to provide the conditions. When instantiating <tt>choice<T></tt>, we forward \a T to the <tt>select_</tt> set of overloads. Because of <a href="http://en.wikipedia.org/wiki/SFINAE">SFINAE</a>, the overload set will only contain those instantiations, for which template expansion does not fail. So, if \a T has an integer \c value member, both \c select_ overloads are ok and the call <tt>select_<T>(0)</tt> will choose the first (case 0) variant, since the argument \c 0 is better matched by \c int than by <tt>...</tt>. However, if \a T does not have an integer \c value member, expansion for the first overload fails and the overload set only contains the second case. \ref SENF_MPL_RV() internally uses \c sizeof to find out, \e which overload was selected and returns the senf::mpl::rv-argument of that overloads return type. For this to work, the \c select_ functions need not be implemented since no code is generated and \c select_ is never called. This number is than forwarded as template argument to \c select which is specialized for each case. Therefore, <tt>choice\<A\></tt> has a \c frobble() member whereas <tt>choice\<B\></tt> has a \c dazzle() member. \see \ref SENF_MPL_RV
char senf::mpl::rv< n >::_[SENF_MPL_RV_ALIGNMENT][n+1] |