
https://svn.lrde.epita.fr/svn/oln/trunk/static Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add an abstraction manipulator. * stc/properties.hh (std::is_a): New helper. (stc_super, stc_pseudosuper, stc_typeof): Simplify the definitions of these macros, using their ``underscored'' version. (stc_typeof_in_namespace, stc_typeof_in_namespace_): New macro. * tests/properties.cc: Typos in comments. stc/properties.hh | 54 +++++++++++++++++++++++++++++++++++++++++++--------- tests/properties.cc | 4 +-- 2 files changed, 47 insertions(+), 11 deletions(-) Index: tests/properties.cc --- tests/properties.cc (revision 460) +++ tests/properties.cc (working copy) @@ -76,7 +76,7 @@ // Forward declaration. struct B; - // Warning, this sugar might me remove from properties.hh. + // Warning, this sugar might be removed in the future. stc_set_super(B, A); /// Types associated to my::B. @@ -122,7 +122,7 @@ // from B's vtypes (see the specialization // types<category::my_cat, C>). - // Warning, this sugar might me remove from properties.hh. + // Warning, this sugar might be removed in the future. /// Link to B (``pseudo'' inheritance). stc_set_pseudosuper(C, B); Index: stc/properties.hh --- stc/properties.hh (revision 460) +++ stc/properties.hh (working copy) @@ -345,6 +345,26 @@ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n +/*---------------------. +| Abstraction helper. | +`---------------------*/ + +namespace stc +{ + /// Allow the manipulation of an abstraction (i.e., a template type) + /// as a plain type. + template <template <typename> class abstraction> + struct is_a + { + template <typename E> + struct instantiated_with + { + typedef abstraction<E> ret; + }; + }; +} + + /*---------. | Macros. | `---------*/ @@ -373,29 +393,45 @@ typedef PseudoSuper ret; \ } -/// \def Get the immediate base class of T (version with typename). +/// \def Get the immediate base class of T (version to be used inside +/// a template). # define stc_super(T) \ - typename set_super_type<T>::ret + typename stc_super_(T) -/// \def Get the immediate base class of T (version without typename). +/// \def Get the immediate base class of T (version to be used outside +/// a template). # define stc_super_(T) \ set_super_type<T>::ret -/// \def Get the pseudosuper class of T (version with typename). +/// \def Get the pseudosuper class of T (version to be used inside a +/// template). # define stc_pseudosuper(T) \ - typename set_pseudosuper_type<T>::ret + typename stc_pseudosuper_(T) -/// \def Get the pseudosuper class of T (version without typename). +/// \def Get the pseudosuper class of T (version to be used outside a +/// template). # define stc_pseudosuper_(T) \ set_pseudosuper_type<T>::ret -/// Get the property \a Typedef from \a FromType (version with typename). +/// Get the property \a Typedef from \a FromType (version to be used +/// inside a template). #define stc_typeof(Category, FromType, Typedef) \ - typename typeof_<Category, FromType, typedef_:: Typedef##_type >::ret + typename stc_typeof_(Category, FromType, Typedef) -/// Get the property \a Typedef from \a FromType (version without typename). +/// Get the property \a Typedef from \a FromType (version to be used +/// outside a template). #define stc_typeof_(Category, FromType, Typedef) \ typeof_<Category, FromType, typedef_:: Typedef##_type >::ret +/// Get the property \a Typedef, declared in \a Namespace, from \a +/// FromType (version to be used inside a template). +#define stc_typeof_in_namespace(Namespace, Category, FromType, Typedef) \ + typename stc_typeof_in_namespace_(Namespace, Category, FromType, Typedef) + +/// Get the property \a Typedef, declared in \a Namespace, from \a +/// FromType (version to be used outside a template). +#define stc_typeof_in_namespace_(Namespace, Category, FromType, Typedef) \ + Namespace::typeof_<Category, FromType, \ + Namespace::typedef_:: Typedef##_type >::ret #endif // ! STATIC_PROPERTIES_HH