From fd4177321bdaeac39114651e1f662dd151fda428 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Thu, 13 Oct 2016 19:01:12 +0200 Subject: [PATCH] functors with arbitrary nr of arguments --- AMDiS/src/expressions/expr_traits.hpp | 16 ++++----- AMDiS/src/traits/basic.hpp | 48 +++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/AMDiS/src/expressions/expr_traits.hpp b/AMDiS/src/expressions/expr_traits.hpp index 15c9bc1b..1486c060 100644 --- a/AMDiS/src/expressions/expr_traits.hpp +++ b/AMDiS/src/expressions/expr_traits.hpp @@ -41,10 +41,10 @@ namespace AMDiS struct is_constant : is_numeric::type {}; template - struct is_constant > : boost::mpl::bool_ {}; + struct is_constant > : bool_ {}; template - struct is_constant > : boost::mpl::bool_ {}; + struct is_constant > : bool_ {}; // type-traits for terms @@ -56,18 +56,18 @@ namespace AMDiS // type-traits for arguments, filter terms and constants // ___________________________________________________________________________ template - struct is_valid_arg : boost::mpl::or_ + struct is_valid_arg : or_ < typename is_expr::type, typename is_constant::type >::type {}; template - struct is_valid_arg2 : boost::mpl::and_ + struct is_valid_arg2 : and_ < typename is_valid_arg::type, typename is_valid_arg::type, - typename boost::mpl::or_ + typename or_ < typename is_expr::type, typename is_expr::type @@ -75,12 +75,12 @@ namespace AMDiS >::type {}; template - struct is_valid_arg3 : boost::mpl::and_ + struct is_valid_arg3 : and_ < typename is_valid_arg::type, typename is_valid_arg::type, typename is_valid_arg::type, - typename boost::mpl::or_ + typename or_ < typename is_expr::type, typename is_expr::type, @@ -92,7 +92,7 @@ namespace AMDiS // expressions template < typename T > - struct category::type >::type > + struct category::type >::type > { typedef tag::expression tag; typedef typename T::value_type value_type; diff --git a/AMDiS/src/traits/basic.hpp b/AMDiS/src/traits/basic.hpp index 462d5598..f6e54f51 100644 --- a/AMDiS/src/traits/basic.hpp +++ b/AMDiS/src/traits/basic.hpp @@ -35,7 +35,7 @@ #include #endif -#ifdef HAS_CPP11 +#ifdef HAS_CXX11 #include #endif @@ -44,11 +44,52 @@ namespace AMDiS // introduce some shortcuts for boost::mpl // --------------------------------------- + +#ifdef HAS_CXX11 + template + using bool_ = std::integral_constant; + + using true_ = bool_; + using false_ = bool_; + + namespace aux + { + template struct or_; + + template + struct or_ : bool_::value> {}; + + template <> + struct or_<> : false_ {}; + + template struct and_; + + template + struct and_ : bool_::value> {}; + + template <> + struct and_<> : true_ {}; + + } // end namespace aux + + + template + using and_ = aux::and_; + + template + using or_ = aux::or_; + + template + using not_ = bool_; + +#else using boost::mpl::bool_; using boost::mpl::true_; using boost::mpl::false_; using boost::mpl::and_; using boost::mpl::or_; + using boost::mpl::not_; +#endif using boost::enable_if; using boost::enable_if_c; @@ -74,13 +115,8 @@ namespace AMDiS boost::is_same< typename mtl::Addable::result_type, no_valid_type > > {}; -#ifdef HAS_CPP11 - template - struct is_trivially_copyable : std::is_trivially_copyable {}; -#else template struct is_trivially_copyable : boost::is_pod {}; -#endif template struct equal : boost::mpl::if_c< A == B, true_, false_ > {}; -- GitLab