https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Add mlc_propagate_typedef_from; fix mlc::eq_ and _neq_.
* mlc/typedef.hh (mlc_propagate_typedef_from): New macro.
* mlc/cmp.hh (eq_, neq_): Change assertions so that it works on value
types.
cmp.hh | 44 ++++++++++++++++++++++++++++++++++----------
typedef.hh | 9 +++++++++
2 files changed, 43 insertions(+), 10 deletions(-)
Index: mlc/typedef.hh
--- mlc/typedef.hh (revision 477)
+++ mlc/typedef.hh (working copy)
@@ -34,6 +34,15 @@
# include <mlc/cmp.hh>
+/*! \macro mlc_propagate_typedef_from(Typedef, Type)
+**
+** FIXME: doc and say "end with ';'"
+*/
+# define mlc_propagate_typedef_from(Typedef, Type) \
+ typedef typename Type :: Typedef Typedef
+
+
+
/*! \macro mlc_decl_typedef(TypedefName)
**
** This macro is for declaring the use of a typedef embedded in
Index: mlc/cmp.hh
--- mlc/cmp.hh (revision 477)
+++ mlc/cmp.hh (working copy)
@@ -47,6 +47,9 @@
/// \{
/// Macros mlc_something(T) corresponding to mlc::something_<T>.
+# define mlc_is_bexpr(T) mlc::is_bexpr_<T>
+# define mlc_is_not_bexpr(T) mlc::is_not_bexpr_<T>
+
# define mlc_is_found(T) mlc::is_found_<T>
# define mlc_is_not_found(T) mlc::is_not_found_<T>
@@ -67,6 +70,10 @@
namespace mlc
{
+ /*----------------------------------------------------------------.
+ | Syntactic sugar for checking that a type is a value / a bexpr. |
+ `-----------------------------------------------------------------*/
+
/// Check whether \a T is a mlc::abstract::value.
template <typename T>
struct is_value : public mlc_is_a(T, mlc::abstract::value)::bexpr
@@ -80,45 +87,62 @@
};
+ /// Check whether \a T is a mlc::abstract::bexpr.
+ template <typename T>
+ struct is_bexpr : public mlc_is_a(T, mlc::abstract::bexpr)::bexpr
+ {
+ };
+
+ /// Check whether \a T is not a mlc::abstract::bexpr.
+ template <typename T>
+ struct is_not_bexpr : public not_<mlc_is_a(T, mlc::abstract::bexpr)>::bexpr
+ {
+ };
+
+
+
+ /*--------------------------.
+ | Comparison between types |
+ `---------------------------*/
/// Equality test between a couple of types.
/// \{
template <typename T1, typename T2>
- struct eq_ : private multiple_assert_< is_not_value<T1>,
- is_not_value<T2> >,
+ struct eq_ : private multiple_assert_< is_not_bexpr<T1>,
+ is_not_bexpr<T2> >,
public bexpr_<false>
{
};
template <typename T>
- struct eq_ <T, T> : private assert_< is_not_value<T> >,
+ struct eq_ <T, T> : private assert_< is_not_bexpr<T> >,
public bexpr_<true>
{
};
/// \}
-
/// Inequality test between a couple of types.
/// \{
template <typename T1, typename T2>
- struct neq_ : private multiple_assert_< is_not_value<T1>,
- is_not_value<T2> >,
+ struct neq_ : private multiple_assert_< is_not_bexpr<T1>,
+ is_not_bexpr<T2> >,
public bexpr_<true>
{
};
template <typename T>
- struct neq_ <T, T> : private assert_< is_not_value<T> >,
+ struct neq_ <T, T> : private assert_< is_not_bexpr<T> >,
public bexpr_<false>
{
};
/// \}
- /*--------------------------------------.
- | Syntactic sugar for flag comparison. |
- `--------------------------------------*/
+
+ /*--------------------------------------------------------------------------.
+ | Syntactic sugar for checking the relationship between a type and a flag. |
+ `---------------------------------------------------------------------------*/
/// Shortcuts for comparison with mlc::not_found.
/// \{