https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Re-enable or_list_ and and_list_.
* tests/or.cc: New file.
* tests/Makefile.am: Update.
* mlc/logic.hh (or_list_, and_list_): Uncomment, update, and bug fix.
* mlc/assert.hh: Fix missing include.
mlc/assert.hh | 4
mlc/logic.hh | 388 +++++++++++++++++++++++++++---------------------------
tests/Makefile.am | 2
tests/or.cc | 23 +++
4 files changed, 223 insertions(+), 194 deletions(-)
Index: tests/or.cc
--- tests/or.cc (revision 0)
+++ tests/or.cc (revision 0)
@@ -0,0 +1,23 @@
+#include <mlc/cmp.hh>
+#include <mlc/logic.hh>
+#include <mlc/assert.hh>
+
+struct alpha;
+struct beta;
+struct gamma;
+struct delta;
+
+int
+main()
+{
+ typedef beta x;
+
+ mlc::assert_< mlc::or_< mlc_eq(x, alpha),
+ mlc_eq(x, beta) >
+ >::check();
+
+ mlc::assert_< mlc::or_list_< mlc_eq(x, alpha),
+ mlc_eq(x, beta),
+ mlc_eq(x, gamma) >
+ >::check();
+}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 431)
+++ tests/Makefile.am (working copy)
@@ -11,6 +11,7 @@
case \
if \
is_a \
+ or \
ret \
switch \
typedef
@@ -18,6 +19,7 @@
case_SOURCES = case.cc
if_SOURCES = if.cc
is_a_SOURCES = is_a.cc
+or_SOURCES = or.cc
ret_SOURCES = ret.cc
switch_SOURCES = switch.cc
typedef_SOURCES = typedef.cc
Index: mlc/logic.hh
--- mlc/logic.hh (revision 431)
+++ mlc/logic.hh (working copy)
@@ -121,200 +121,202 @@
{};
-// /// Internal helpers for logical operators between several Boolean types
-// namespace internal
-// {
-// // FIXME: doc
-
-// template <typename A>
-// struct is_bexpr_or_none_ : public true_ // FIXME: pb using mlc_is_a because of
circular deps
-// {
-// };
-
-
-// // va_eval_
-
-// template <typename A>
-// struct va_eval_
-// {
-// typedef typename A::eval ret;
-// };
-
-// template <>
-// struct va_eval_ <none>
-// {
-// typedef none ret;
-// };
-
-
-// // or_list_2_
-
-// template <typename A1, typename A2>
-// struct or_list_2_
-// : public or_<A1, A2>::eval
-// {};
-
-// template <>
-// struct or_list_2_ <none, none>
-// : public true_
-// {};
-
-// template <typename A1>
-// struct or_list_2_ <A1, none>
-// : public A1
-// {};
-
-// template <typename A2>
-// struct or_list_2_ <none, A2>; // forbidden
-
-// // or_list_4_
-
-// 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
-// {};
-
-// template <>
-// struct or_list_4_ <none, none, none, none>
-// : public true_
-// {};
-
-// // or_list_
-
-// 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
-// {};
-
-
-// // and_list_2_
-
-// template <typename A1, typename A2>
-// struct and_list_2_
-// : public and_<A1, A2>::eval
-// {};
-
-// template <>
-// struct and_list_2_ <none, none>
-// : public true_
-// {};
-
-// template <typename A1>
-// struct and_list_2_ <A1, none>
-// : public A1
-// {};
-
-// template <typename A2>
-// struct and_list_2_ <none, A2>; // forbidden
-
-// // and_list_4_
-
-// 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
-// {};
-
-// template <>
-// struct and_list_4_ <none, none, none, none>
-// : public true_
-// {};
-
-// // and_list_
-
-// 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
-// {};
-
-// } // end of mlc::internal
-
-
-
-// /*! \class mlc::or_list_<..>
-// **
-// ** Logical n-ary 'or' operator on a set of Boolean expression types.
-// ** The number of arguments (parameters) should be at least 3 and at
-// ** most 8. This class is also a Boolean expression type.
-// **
-// ** Sample use:
-// ** mlc::or_list_< mlc::eq_<T, int>,
-// ** mlc_is_a(T, mlc::int_),
-// ** mlc_is_a(T, my::integer) >
-// **
-// ** \see mlc::or_<L,R> mlc::and_list_<..>
-// */
-
-// template <typename A1,
-// typename A2,
-// typename A3,
-// typename A4 = none,
-// typename A5 = none,
-// typename A6 = none,
-// typename A7 = none,
-// typename A8 = none>
-// 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>,
-// internal::is_bexpr_or_none_<A5>,
-// 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 >
-// {
-// };
-
-
-
-// /*! \class mlc::and_list_<..>
-// **
-// ** Logical n-ary 'and' operator on a set of Boolean expression types.
-// ** The number of arguments (parameters) should be at least 3 and at
-// ** most 8. This class is also a Boolean expression type.
-// **
-// ** \see mlc::and_<L,R> mlc::or_list_<..>
-// */
-
-// template <typename A1,
-// typename A2,
-// typename A3,
-// typename A4 = none,
-// typename A5 = none,
-// typename A6 = none,
-// typename A7 = none,
-// typename A8 = none>
-// 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>,
-// internal::is_bexpr_or_none_<A5>,
-// 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 >
-// {
-// };
+
+ /// Internal helpers for logical operators between several Boolean types
+
+ namespace internal
+ {
+ // FIXME: doc
+
+ template <typename A>
+ struct is_bexpr_or_none_ : public true_ // FIXME: pb using mlc_is_a because of
circular deps
+ {
+ };
+
+
+ // va_eval_
+
+ template <typename A>
+ struct va_eval_
+ {
+ typedef typename A::eval ret;
+ };
+
+ template <>
+ struct va_eval_ <none>
+ {
+ typedef none ret;
+ };
+
+
+ // or_list_2_
+
+ template <typename A1, typename A2>
+ struct or_list_2_
+ : public or_<A1, A2>::eval
+ {};
+
+ template <>
+ struct or_list_2_ <none, none>
+ : public false_
+ {};
+
+ template <typename A1>
+ struct or_list_2_ <A1, none>
+ : public A1
+ {};
+
+ template <typename A2>
+ struct or_list_2_ <none, A2>; // forbidden
+
+ // or_list_4_
+
+ 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
+ {};
+
+ template <>
+ struct or_list_4_ <none, none, none, none>
+ : public false_
+ {};
+
+ // or_list_
+
+ 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
+ {};
+
+
+ // and_list_2_
+
+ template <typename A1, typename A2>
+ struct and_list_2_
+ : public and_<A1, A2>::eval
+ {};
+
+ template <>
+ struct and_list_2_ <none, none>
+ : public true_
+ {};
+
+ template <typename A1>
+ struct and_list_2_ <A1, none>
+ : public A1
+ {};
+
+ template <typename A2>
+ struct and_list_2_ <none, A2>; // forbidden
+
+ // and_list_4_
+
+ 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
+ {};
+
+ template <>
+ struct and_list_4_ <none, none, none, none>
+ : public true_
+ {};
+
+ // and_list_
+
+ 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
+ {};
+
+ } // end of mlc::internal
+
+
+
+ /*! \class mlc::or_list_<..>
+ **
+ ** Logical n-ary 'or' operator on a set of Boolean expression types.
+ ** The number of arguments (parameters) should be at least 3 and at
+ ** most 8. This class is also a Boolean expression type.
+ **
+ ** Sample use:
+ ** mlc::or_list_< mlc::eq_<T, int>,
+ ** mlc_is_a(T, mlc::int_),
+ ** mlc_is_a(T, my::integer) >
+ **
+ ** \see mlc::or_<L,R> mlc::and_list_<..>
+ */
+
+ template <typename A1,
+ typename A2,
+ typename A3,
+ typename A4 = none,
+ typename A5 = none,
+ typename A6 = none,
+ typename A7 = none,
+ typename A8 = none>
+ 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>,
+ internal::is_bexpr_or_none_<A5>,
+ 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 >
+ {
+ };
+
+
+
+ /*! \class mlc::and_list_<..>
+ **
+ ** Logical n-ary 'and' operator on a set of Boolean expression types.
+ ** The number of arguments (parameters) should be at least 3 and at
+ ** most 8. This class is also a Boolean expression type.
+ **
+ ** \see mlc::and_<L,R> mlc::or_list_<..>
+ */
+
+ template <typename A1,
+ typename A2,
+ typename A3,
+ typename A4 = none,
+ typename A5 = none,
+ typename A6 = none,
+ typename A7 = none,
+ typename A8 = none>
+ 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>,
+ internal::is_bexpr_or_none_<A5>,
+ 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 >
+ {
+ };
} // end of namespace mlc
Index: mlc/assert.hh
--- mlc/assert.hh (revision 431)
+++ mlc/assert.hh (working copy)
@@ -28,6 +28,8 @@
#ifndef METALIC_ASSERT_HH
# define METALIC_ASSERT_HH
+# include <mlc/flags.hh>
+
namespace mlc
@@ -89,7 +91,7 @@
struct no_bexpr
{
- typedef dummy is_true;
+ typedef mlc::dummy is_true;
};