https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Remove remaining dependencies between Boolean values and exprs.
* mlc/bool.hh (bool_): Remove inheritance from bexpr_is_.
* mlc/bexpr.hh (bexpr_is_): Rename as...
(bexpr_): ...this.
(bexpr_<b>::bexpr): New typedef so that bexprs can be simplified.
* tests/if.cc: Update.
* mlc/logic.hh: Add macros; add static checks; update.
* mlc/if.hh: Add static check.
* mlc/implies.hh: Add static check and update.
* mlc/abort.hh: Update.
* mlc/is_a.hh (where_): Add static check.
Update.
* mlc/case.hh: Update.
* mlc/cmp.hh: Update.
mlc/abort.hh | 2
mlc/bexpr.hh | 63 ++++++++---------
mlc/bool.hh | 3
mlc/case.hh | 13 ++-
mlc/cmp.hh | 8 +-
mlc/if.hh | 9 ++
mlc/implies.hh | 29 +++++---
mlc/is_a.hh | 10 +-
mlc/logic.hh | 201 +++++++++++++++++++++++++++++++++++++++++++--------------
tests/if.cc | 4 -
10 files changed, 235 insertions(+), 107 deletions(-)
Index: tests/if.cc
--- tests/if.cc (revision 443)
+++ tests/if.cc (working copy)
@@ -10,9 +10,9 @@
int
main()
{
- typedef mlc_if_(mlc::true_, alpha, beta) x;
+ typedef mlc_if_(mlc::bexpr_<true>, alpha, beta) x;
mlc::assert_< mlc_eq(x, alpha) >::check();
- typedef mlc_if_(mlc::false_, gamma, delta) y;
+ typedef mlc_if_(mlc::bexpr_<false>, gamma, delta) y;
mlc::assert_< mlc_eq(y, delta) >::check();
}
Index: mlc/bool.hh
--- mlc/bool.hh (revision 443)
+++ mlc/bool.hh (working copy)
@@ -57,8 +57,7 @@
*/
template <bool b>
- struct bool_ : public bexpr_is_<b>,
- public abstract::boolean
+ struct bool_ : public abstract::boolean
{
/*! \typedef type
Index: mlc/logic.hh
--- mlc/logic.hh (revision 443)
+++ mlc/logic.hh (working copy)
@@ -28,26 +28,71 @@
#ifndef METALIC_LOGIC_HH
# define METALIC_LOGIC_HH
-# include <mlc/bool.hh>
# include <mlc/bexpr.hh>
# include <mlc/assert.hh>
+# include <mlc/is_a.hh>
+
+
+
+
+/// Macros corresponding to binary logic Boolean expressions.
+/// \{
+
+# define mlc_and(L, R) mlc::and_ < L, R >
+# define mlc_nand(L, R) mlc::nand_< L, R >
+# define mlc_or(L, R) mlc::or_ < L, R >
+# define mlc_nor(L, R) mlc::nor_ < L, R >
+# define mlc_xor(L, R) mlc::xor_ < L, R >
+# define mlc_xnor(L, R) mlc::xnor_< L, R >
+
+/// \}
+
namespace mlc
{
+ namespace ERROR
+ {
+
+ struct PARAMETER_OF_mlc_not_SHOULD_BE_A_BEXPR;
+
+ struct FIRST_PARAMETER_OF_mlc_and_SHOULD_BE_A_BEXPR;
+ struct FIRST_PARAMETER_OF_mlc_nand_SHOULD_BE_A_BEXPR;
+ struct FIRST_PARAMETER_OF_mlc_or_SHOULD_BE_A_BEXPR;
+ struct FIRST_PARAMETER_OF_mlc_nor_SHOULD_BE_A_BEXPR;
+ struct FIRST_PARAMETER_OF_mlc_xor_SHOULD_BE_A_BEXPR;
+ struct FIRST_PARAMETER_OF_mlc_xnor_SHOULD_BE_A_BEXPR;
+
+ struct SECOND_PARAMETER_OF_mlc_and_SHOULD_BE_A_BEXPR;
+ struct SECOND_PARAMETER_OF_mlc_nand_SHOULD_BE_A_BEXPR;
+ struct SECOND_PARAMETER_OF_mlc_or_SHOULD_BE_A_BEXPR;
+ struct SECOND_PARAMETER_OF_mlc_nor_SHOULD_BE_A_BEXPR;
+ struct SECOND_PARAMETER_OF_mlc_xor_SHOULD_BE_A_BEXPR;
+ struct SECOND_PARAMETER_OF_mlc_xnor_SHOULD_BE_A_BEXPR;
+
+ } // end of mlc::ERROR
+
+
+
/*! \class mlc::not_<T>
**
** Logical unary 'not' operator on a Boolean expression type. This
** class is also a Boolean expression type.
*/
+
template <typename T>
struct not_
- : public bexpr_is_<( !mlc_bool(T) )>
+
+ : private assert_< mlc_is_a(T, mlc::abstract::bexpr),
+ mlc::ERROR::PARAMETER_OF_mlc_not_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( !mlc_bool(T) )>
{};
+
/*! \class mlc::and_<L,R>
**
** Logical binary 'and' operator on a couple of Boolean expression
@@ -55,12 +100,21 @@
**
** \see mlc::and_list_<..>
*/
+
template <typename L, typename R>
struct and_
- : public bexpr_is_<( mlc_bool(L) && mlc_bool(R) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_and_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_and_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( mlc_bool(L) && mlc_bool(R) )>
{};
+
/*! \class mlc::nand_<L,R>
**
** Logical binary 'not and' operator on a couple of Boolean
@@ -68,12 +122,21 @@
**
** Design note: an equivalent is mlc::not_< mlc::and_<L,R> >.
*/
+
template <typename L, typename R>
struct nand_
- : public bexpr_is_<( !(mlc_bool(L) && mlc_bool(R)) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_nand_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_nand_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( !(mlc_bool(L) && mlc_bool(R)) )>
{};
+
/*! \class mlc::or_<L,R>
**
** Logical binary 'or' operator on a couple of Boolean expression
@@ -81,12 +144,21 @@
**
** \see mlc::or_list_<..>
*/
+
template <typename L, typename R>
struct or_
- : public bexpr_is_<( mlc_bool(L) || mlc_bool(R) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_or_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_or_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( mlc_bool(L) || mlc_bool(R) )>
{};
+
/*! \class mlc::nor_<L,R>
**
** Logical binary 'not or' operator on a couple of Boolean
@@ -94,20 +166,37 @@
**
** Design note: an equivalent is mlc::not_< mlc::or_<L,R> >.
*/
+
template <typename L, typename R>
struct nor_
- : public bexpr_is_<( !(mlc_bool(L) || mlc_bool(R)) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_nor_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_nor_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( !(mlc_bool(L) || mlc_bool(R)) )>
{};
+
/*! \class mlc::xor_<L,R>
**
** Logical binary 'exclusive or' operator on a couple of Boolean
** expression types. This class is also a Boolean expression type.
*/
+
template <typename L, typename R>
struct xor_
- : public bexpr_is_<( mlc_bool(L) != mlc_bool(R) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_xor_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_xor_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( mlc_bool(L) != mlc_bool(R) )>
{};
@@ -116,9 +205,17 @@
** Logical binary 'exclusive not or' operator on a couple of Boolean
** expression types. This class is also a Boolean expression type.
*/
+
template <typename L, typename R>
struct xnor_
- : public bexpr_is_<( !(mlc_bool(L) != mlc_bool(R)) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_xnor_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_xnor_SHOULD_BE_A_BEXPR >,
+
+ public bexpr_<( !(mlc_bool(L) != mlc_bool(R)) )>
{};
@@ -131,21 +228,27 @@
// FIXME: doc
template <typename A>
- struct is_bexpr_or_none_ : public true_ // FIXME: pb using mlc_is_a because of
circular deps
+ struct is_bexpr_or_none_
+ : public mlc_is_a(A, mlc::abstract::bexpr)
{
};
+ template <>
+ struct is_bexpr_or_none_ < none >
+ : public bexpr_<true>
+ {
+ };
- // va_eval_
+ // va_bexpr_
template <typename A>
- struct va_eval_
+ struct va_bexpr_
{
- typedef typename A::eval ret;
+ typedef typename A::bexpr ret;
};
template <>
- struct va_eval_ <none>
+ struct va_bexpr_ <none>
{
typedef none ret;
};
@@ -155,17 +258,17 @@
template <typename A1, typename A2>
struct or_list_2_
- : public or_<A1, A2>::eval
+ : public or_<A1, A2>
{};
template <>
struct or_list_2_ <none, none>
- : public false_
+ : public bexpr_<false>
{};
template <typename A1>
struct or_list_2_ <A1, none>
- : public A1
+ : public A1::bexpr
{};
template <typename A2>
@@ -175,13 +278,13 @@
template <typename A1, typename A2, typename A3, typename A4>
struct or_list_4_
- : public or_list_2_< typename or_list_2_<A1, A2>::eval,
- typename or_list_2_<A3, A4>::eval >::eval
+ : public or_list_2_< typename or_list_2_<A1, A2>::bexpr,
+ typename or_list_2_<A3, A4>::bexpr >::bexpr
{};
template <>
struct or_list_4_ <none, none, none, none>
- : public false_
+ : public bexpr_<false>
{};
// or_list_
@@ -189,8 +292,8 @@
template <typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8>
struct or_list_
- : public or_list_2_< typename or_list_4_<A1, A2, A3, A4>::eval,
- typename or_list_4_<A5, A6, A7, A8>::eval >::eval
+ : public or_list_2_< typename or_list_4_<A1, A2, A3, A4>::bexpr,
+ typename or_list_4_<A5, A6, A7, A8>::bexpr >::bexpr
{};
@@ -198,12 +301,12 @@
template <typename A1, typename A2>
struct and_list_2_
- : public and_<A1, A2>::eval
+ : public and_<A1, A2>
{};
template <>
struct and_list_2_ <none, none>
- : public true_
+ : public bexpr_<true>
{};
template <typename A1>
@@ -218,13 +321,13 @@
template <typename A1, typename A2, typename A3, typename A4>
struct and_list_4_
- : public and_list_2_< typename and_list_2_<A1, A2>::eval,
- typename and_list_2_<A3, A4>::eval >::eval
+ : public and_list_2_< typename and_list_2_<A1, A2>::bexpr,
+ typename and_list_2_<A3, A4>::bexpr >::bexpr
{};
template <>
struct and_list_4_ <none, none, none, none>
- : public true_
+ : public bexpr_<true>
{};
// and_list_
@@ -232,8 +335,8 @@
template <typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8>
struct and_list_
- : public and_list_2_< typename and_list_4_<A1, A2, A3, A4>::eval,
- typename and_list_4_<A5, A6, A7, A8>::eval >::eval
+ : public and_list_2_< typename and_list_4_<A1, A2, A3, A4>::bexpr,
+ typename and_list_4_<A5, A6, A7, A8>::bexpr >::bexpr
{};
} // end of mlc::internal
@@ -262,7 +365,9 @@
typename A6 = none,
typename A7 = none,
typename A8 = none>
- struct or_list_ : private multiple_assert_< internal::is_bexpr_or_none_<A1>,
+ struct or_list_ :
+
+ private multiple_assert_< internal::is_bexpr_or_none_<A1>,
internal::is_bexpr_or_none_<A2>,
internal::is_bexpr_or_none_<A3>,
internal::is_bexpr_or_none_<A4>,
@@ -270,14 +375,15 @@
internal::is_bexpr_or_none_<A6>,
internal::is_bexpr_or_none_<A7>,
internal::is_bexpr_or_none_<A8> >,
- public internal::or_list_< typename internal::va_eval_<A1>::ret,
- typename internal::va_eval_<A2>::ret,
- typename internal::va_eval_<A3>::ret,
- typename internal::va_eval_<A4>::ret,
- typename internal::va_eval_<A5>::ret,
- typename internal::va_eval_<A6>::ret,
- typename internal::va_eval_<A7>::ret,
- typename internal::va_eval_<A8>::ret >
+
+ public internal::or_list_< typename internal::va_bexpr_<A1>::ret,
+ typename internal::va_bexpr_<A2>::ret,
+ typename internal::va_bexpr_<A3>::ret,
+ typename internal::va_bexpr_<A4>::ret,
+ typename internal::va_bexpr_<A5>::ret,
+ typename internal::va_bexpr_<A6>::ret,
+ typename internal::va_bexpr_<A7>::ret,
+ typename internal::va_bexpr_<A8>::ret >
{
};
@@ -300,7 +406,9 @@
typename A6 = none,
typename A7 = none,
typename A8 = none>
- struct and_list_ : private multiple_assert_< internal::is_bexpr_or_none_<A1>,
+ struct and_list_ :
+
+ private multiple_assert_< internal::is_bexpr_or_none_<A1>,
internal::is_bexpr_or_none_<A2>,
internal::is_bexpr_or_none_<A3>,
internal::is_bexpr_or_none_<A4>,
@@ -308,14 +416,15 @@
internal::is_bexpr_or_none_<A6>,
internal::is_bexpr_or_none_<A7>,
internal::is_bexpr_or_none_<A8> >,
- public internal::and_list_< typename internal::va_eval_<A1>::ret,
- typename internal::va_eval_<A2>::ret,
- typename internal::va_eval_<A3>::ret,
- typename internal::va_eval_<A4>::ret,
- typename internal::va_eval_<A5>::ret,
- typename internal::va_eval_<A6>::ret,
- typename internal::va_eval_<A7>::ret,
- typename internal::va_eval_<A8>::ret >
+
+ public internal::and_list_< typename internal::va_bexpr_<A1>::ret,
+ typename internal::va_bexpr_<A2>::ret,
+ typename internal::va_bexpr_<A3>::ret,
+ typename internal::va_bexpr_<A4>::ret,
+ typename internal::va_bexpr_<A5>::ret,
+ typename internal::va_bexpr_<A6>::ret,
+ typename internal::va_bexpr_<A7>::ret,
+ typename internal::va_bexpr_<A8>::ret >
{
};
Index: mlc/if.hh
--- mlc/if.hh (revision 443)
+++ mlc/if.hh (working copy)
@@ -51,6 +51,12 @@
namespace mlc
{
+ namespace ERROR
+ {
+ struct FIXME;
+
+ } // end of mlc::ERROR
+
namespace internal
{
@@ -89,7 +95,8 @@
template <typename cond_type, typename then_type, typename else_type>
struct if_ :
// FIXME: enable the static assertion below!!!
- private assert_< mlc_is_a(cond_type, mlc::abstract::bexpr) >,
+ private assert_< mlc_is_a(cond_type, mlc::abstract::bexpr),
+ mlc::ERROR::FIXME >,
public internal::if_ < mlc_bool(cond_type), then_type, else_type >
{
};
Index: mlc/implies.hh
--- mlc/implies.hh (revision 443)
+++ mlc/implies.hh (working copy)
@@ -29,9 +29,11 @@
# define METALIC_IMPLIES_HH
# include <mlc/bexpr.hh>
+# include <mlc/assert.hh>
+# include <mlc/is_a.hh>
-/*! \def mlc_implies(Left_BExpr, Right_BExpr)
+/*! \def mlc_implies(L, R)
**
** Macro corresponding to mlc::implies_<L, R>, for use in a template
** context.
@@ -39,29 +41,40 @@
** \see mlc::implies_<L, R>
*/
-# define mlc_implies(Left_BExpr, Right_BExpr) \
- mlc::bexpr_< typename mlc::implies_<Left_BExpr, Right_BExpr>::ret >
-
-# define mlc_implies_(Left_BExpr, Right_BExpr) \
- mlc::implies_<Left_BExpr, Right_BExpr>::ret
+# define mlc_implies(L, R) mlc::implies_<L, R>
namespace mlc
{
+ namespace ERROR
+ {
+ struct FIRST_PARAMETER_OF_mlc_implies_SHOULD_BE_A_BEXPR;
+ struct SECOND_PARAMETER_OF_mlc_implies_SHOULD_BE_A_BEXPR;
+
+ } // end of namespace mlc::ERROR
+
+
/*! \class mlc::implies_<L, R>
**
** Logical implication "L => R" with L and R being Boolean
** expression types. This class is also a Boolean expression type.
**
** Sample use:
- ** mlc::implies_< mlc_is_builtin(T), mlc_eq(T, int) >::assert();
+ ** mlc::assert_< mlc::implies_< mlc_is_builtin(T), mlc_eq(T, int) >
>::check();
** which means "if T is a buit-in type, it has to be int".
*/
template <typename L, typename R>
struct implies_
- : public mlc::bexpr_is_<( !mlc_bool(L) || mlc_bool(R) )>
+
+ : private assert_< mlc_is_a(L, mlc::abstract::bexpr),
+ mlc::ERROR::FIRST_PARAMETER_OF_mlc_implies_SHOULD_BE_A_BEXPR >,
+
+ private assert_< mlc_is_a(R, mlc::abstract::bexpr),
+ mlc::ERROR::SECOND_PARAMETER_OF_mlc_implies_SHOULD_BE_A_BEXPR >,
+
+ public mlc::bexpr_<( !mlc_bool(L) || mlc_bool(R) )>
{};
} // end of namespace mlc
Index: mlc/abort.hh
--- mlc/abort.hh (revision 443)
+++ mlc/abort.hh (working copy)
@@ -59,7 +59,7 @@
template <typename T>
struct always_false_
- : public bexpr_is_<false>
+ : public bexpr_<false>
{
protected:
always_false_() {}
Index: mlc/is_a.hh
--- mlc/is_a.hh (revision 443)
+++ mlc/is_a.hh (working copy)
@@ -108,7 +108,7 @@
template<class T, class U>
struct ret
- : public mlc::bexpr_is_<( mlc_internal_is_a_result_ )>
+ : public mlc::bexpr_<( mlc_internal_is_a_result_ )>
{
};
};
@@ -131,7 +131,7 @@
template<class T, template < class > class U>
struct ret
- : public mlc::bexpr_is_<( mlc_internal_is_a_result_ )>
+ : public mlc::bexpr_<( mlc_internal_is_a_result_ )>
{
};
};
@@ -154,7 +154,7 @@
template<class T, template < class,class > class U>
struct ret
- : public mlc::bexpr_is_<( mlc_internal_is_a_result_ )>
+ : public mlc::bexpr_<( mlc_internal_is_a_result_ )>
{};
};
@@ -176,7 +176,7 @@
template<class T, template < template < class > class > class
U>
struct ret
- : public mlc::bexpr_is_<( mlc_internal_is_a_result_ )>
+ : public mlc::bexpr_<( mlc_internal_is_a_result_ )>
{};
};
@@ -198,7 +198,7 @@
template<class T, template < template < class,class > class > class
U>
struct ret
- : public mlc::bexpr_is_<( mlc_internal_is_a_result_ )>
+ : public mlc::bexpr_<( mlc_internal_is_a_result_ )>
{};
};
Index: mlc/case.hh
--- mlc/case.hh (revision 443)
+++ mlc/case.hh (working copy)
@@ -28,7 +28,8 @@
#ifndef METALIC_CASE_HH
# define METALIC_CASE_HH
-# include <mlc/bool.hh>
+# include <mlc/bexpr.hh>
+# include <mlc/assert.hh>
# include <mlc/ret.hh>
# include <mlc/is_a.hh>
# include <mlc/implies.hh>
@@ -64,13 +65,17 @@
struct NO_case_STATEMENT_CAN_BE_SELECTED;
struct A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret;
struct A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret;
+ struct PARAMETER_OF_mlc_where_SHOULD_BE_A_BEXPR;
}
template <typename bexpr>
- struct where_ : public mlc_if_( typename bexpr::eval,
- case_selected,
- case_not_selected )
+ struct where_ :
+
+ private assert_< mlc_is_a(bexpr, mlc::abstract::bexpr),
+ mlc::ERROR::PARAMETER_OF_mlc_where_SHOULD_BE_A_BEXPR >,
+
+ public mlc_if_( bexpr, case_selected, case_not_selected )
{
};
Index: mlc/cmp.hh
--- mlc/cmp.hh (revision 443)
+++ mlc/cmp.hh (working copy)
@@ -60,13 +60,13 @@
template <typename T1, typename T2>
struct eq_ : private multiple_assert_< is_not_value<T1>,
is_not_value<T2> >,
- public bexpr_is_<false>
+ public bexpr_<false>
{
};
template <typename T>
struct eq_ <T, T> : private assert_< is_not_value<T> >,
- public bexpr_is_<true>
+ public bexpr_<true>
{
};
/// \}
@@ -76,13 +76,13 @@
template <typename T1, typename T2>
struct neq_ : private multiple_assert_< is_not_value<T1>,
is_not_value<T2> >,
- public bexpr_is_<true>
+ public bexpr_<true>
{
};
template <typename T>
struct neq_ <T, T> : private assert_< is_not_value<T> >,
- public bexpr_is_<false>
+ public bexpr_<false>
{
};
/// \}
Index: mlc/bexpr.hh
--- mlc/bexpr.hh (revision 443)
+++ mlc/bexpr.hh (working copy)
@@ -54,9 +54,9 @@
**
** When you define a new class for a Boolean expression type, you
** should not directly derive from this class from fom its
- ** subclass: bexpr_is_<b>.
+ ** subclass: bexpr_<b>.
**
- ** \see bexpr_is_<b>
+ ** \see bexpr_<b>
*/
struct bexpr : public type
@@ -68,7 +68,7 @@
- /*! \class mlc::bexpr_is_<b>
+ /*! \class mlc::bexpr_<b>
**
** Base class for any class of mlc Boolean expression types.
** When you define a new class for a Boolean expression type, you
@@ -77,50 +77,57 @@
** This class provides the typedef 'eval' which evaluates to either
** mlc::true_ or mlc::false_ the expression.
**
- ** \see mlc::bexpr_is_<true>, mlc::bexpr_is_<false>
+ ** \see mlc::bexpr_<true>, mlc::bexpr_<false>
*/
- template <bool b> struct bexpr_is_;
+ template <bool b> struct bexpr_;
- /*! \class mlc::bexpr_is_<true>
+ /*! \class mlc::bexpr_<true>
**
- ** Specialization of mlc::bexpr_is_<b> when b is 'true'. This class
+ ** Specialization of mlc::bexpr_<b> when b is 'true'. This class
** provides the typedef member 'is_true' to every Boolean expression
** type that evaluates to true_.
**
- ** \see mlc::bexpr_is_<b>, mlc::bexpr_is_<false>
+ ** \see mlc::bexpr_<b>, mlc::bexpr_<false>
*/
template <>
- struct bexpr_is_ < true > : public abstract::bexpr
+ struct bexpr_ < true > : public abstract::bexpr
{
+ // FIXME: doc
typedef mlc::true_ eval;
/*! \typedef is_true
**
** This member is inherited in every Boolean expression type that
** evaluates to true_. Conversely, such member does not appear in
- ** bexpr_is_<false> so it does not exist in every Boolean
+ ** bexpr_<false> so it does not exist in every Boolean
** expression type that evaluates to false_.
*/
typedef mlc::dummy is_true;
+
+ // FIXME: doc
+ typedef bexpr_<true> bexpr;
};
- /*! \class mlc::bexpr_is_<false>
+
+ /*! \class mlc::bexpr_<false>
**
- ** Specialization of mlc::bexpr_is_<b> when b is 'false'. This class
+ ** Specialization of mlc::bexpr_<b> when b is 'false'. This class
** does not provide the typedef member 'is_true' to every Boolean expression
** type that evaluates to false_.
**
- ** \see mlc::bexpr_is_<b>, mlc::bexpr_is_<true>
+ ** \see mlc::bexpr_<b>, mlc::bexpr_<true>
*/
template <>
- struct bexpr_is_ < false > : public abstract::bexpr
+ struct bexpr_ < false > : public abstract::bexpr
{
typedef mlc::false_ eval;
+
+ typedef bexpr_<false> bexpr;
};
@@ -129,31 +136,19 @@
namespace internal
{
- /// \class mlc::internal::bool_of_<bexpr>
+ /// \class mlc::internal::bool_<bexpr>
/// \brief Returns the bool value corresponding to a Boolean expression type.
/// \note Internal class, don't use it directly.
template <typename bexpr>
- struct bool_of_
+ struct bool_of_bexpr_
// FIXME: commented below to avoid circular dependances
// : private assert_< mlc_is_a(bexpr, mlc::abstract::bexpr) >
{
- // 1) the bexpr evaluates to either mlc::true_ or mlc::false_
- // so the expected result comes from the value of b in
- // mlc::bool_<b>
- // 2) retrieving b is performed by the specialization of
- // internal::bool_of_ provided few lines below
- static const bool ret = internal::bool_of_<typename bexpr::eval>::ret;
- };
-
- /// \class mlc::internal::bool_of_< mlc::bool_<b> >
- /// \brief Specialization of mlc::internal::bool_of_<bexpr>
- /// \note Internal class, don't use it directly.
- /// \see mlc::internal::bool_of_<bexpr>
- template <bool b>
- struct bool_of_ < mlc::bool_<b> >
- {
- static const bool ret = b;
+ // 1) evaluate the bexpr to get either mlc::true_ or mlc::false_
+ typedef typename bexpr::eval eval;
+ // 2) retrieve the Boolean value
+ static const bool ret = eval::value;
};
} // end of namespace mlc::internal
@@ -169,10 +164,10 @@
** Returns the bool value corresponding to a Boolean expression type.
**
** \note Value retrieval is performed by
- ** mlc::internal::bool_of_<Bexpr>
+ ** mlc::internal::bool_of_bexpr_<Bexpr>
*/
-# define mlc_bool(Bexpr) mlc::internal::bool_of_<Bexpr>::ret
+# define mlc_bool(Bexpr) mlc::internal::bool_of_bexpr_<Bexpr>::ret