diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
commit | bb4dd8289b351fae6b55e303f189127a394a1edd (patch) | |
tree | 77c9c35a31b1459dd7988c2448e797d142530c41 /boost/icl/functors.hpp | |
parent | 1a78a62555be32868418fe52f8e330c9d0f95d5a (diff) | |
download | boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2 boost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip |
Imported Upstream version 1.51.0upstream/1.51.0
Diffstat (limited to 'boost/icl/functors.hpp')
-rw-r--r-- | boost/icl/functors.hpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/boost/icl/functors.hpp b/boost/icl/functors.hpp index 1b4758fc5a..2401b2b801 100644 --- a/boost/icl/functors.hpp +++ b/boost/icl/functors.hpp @@ -22,14 +22,14 @@ namespace boost{namespace icl template <typename Type> struct identity_based_inplace_combine : public std::binary_function<Type&, const Type&, void> { - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } + inline static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; // ------------------------------------------------------------------------ template <typename Type> struct unit_element_based_inplace_combine : public std::binary_function<Type&, const Type&, void> { - static Type identity_element() { return boost::icl::unit_element<Type>::value(); } + inline static Type identity_element() { return boost::icl::unit_element<Type>::value(); } }; // ------------------------------------------------------------------------ @@ -49,11 +49,13 @@ namespace boost{namespace icl : public identity_based_inplace_combine<Type> { typedef inplace_erasure<Type> type; + typedef identity_based_inplace_combine<Type> base_type; void operator()(Type& object, const Type& operand)const { if(object == operand) - object = Type(); + //identity_element(); //JODO Old gcc-3.4.4 does not compile this + object = base_type::identity_element(); //<-- but this. } }; @@ -112,8 +114,6 @@ namespace boost{namespace icl void operator()(Type& object, const Type& operand)const { object &= ~operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -140,8 +140,6 @@ namespace boost{namespace icl void operator()(Type& object, const Type& operand)const { object ^= operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; // ------------------------------------------------------------------------ @@ -165,8 +163,6 @@ namespace boost{namespace icl void operator()(Type& object, const Type& operand)const { object ^= operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -180,8 +176,6 @@ namespace boost{namespace icl void operator()(Type& object, const Type& operand)const { insert(object,operand); } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -195,8 +189,6 @@ namespace boost{namespace icl void operator()(Type& object, const Type& operand)const { erase(object,operand); } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -204,14 +196,12 @@ namespace boost{namespace icl // ------------------------------------------------------------------------ template <typename Type> struct inplace_star - : public identity_based_inplace_combine<Type> + : public identity_based_inplace_combine<Type> //JODO unit_element_ { typedef inplace_star<Type> type; void operator()(Type& object, const Type& operand)const { object *= operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -219,14 +209,12 @@ namespace boost{namespace icl // ------------------------------------------------------------------------ template <typename Type> struct inplace_slash - : public identity_based_inplace_combine<Type> + : public identity_based_inplace_combine<Type> //JODO unit_element_ { typedef inplace_slash<Type> type; void operator()(Type& object, const Type& operand)const { object /= operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -243,8 +231,6 @@ namespace boost{namespace icl if(object < operand) object = operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -261,8 +247,6 @@ namespace boost{namespace icl if(object > operand) object = operand; } - - static Type identity_element() { return boost::icl::identity_element<Type>::value(); } }; template<> @@ -340,6 +324,19 @@ namespace boost{namespace icl struct inverse<icl::inplace_min<Type> > { typedef icl::inplace_max<Type> type; }; + template<class Type> + struct inverse<icl::inplace_identity<Type> > + { typedef icl::inplace_erasure<Type> type; }; + + // If a Functor + template<class Functor> + struct inverse + { + typedef typename + remove_reference<typename Functor::first_argument_type>::type argument_type; + typedef icl::inplace_erasure<argument_type> type; + }; + //-------------------------------------------------------------------------- // Inverse inter_section functor |