Commit 9c31ec27 authored by Roland Levillain's avatar Roland Levillain
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@461 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent ca5ef740
2006-04-20 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.
2006-03-23 Roland Levillain <roland@lrde.epita.fr>
Extensible entry points in a class hierarchy (first version).
......
......@@ -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).
#define stc_typeof(Category, FromType, Typedef) \
typename typeof_<Category, FromType, typedef_:: Typedef##_type >::ret
/// Get the property \a Typedef from \a FromType (version to be used
/// inside a template).
#define stc_typeof(Category, FromType, Typedef) \
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
......@@ -76,7 +76,7 @@ namespace my
// 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 @@ namespace my
// 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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment