predicate.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2010-2010: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #ifndef BOOST_ICL_TYPE_TRAITS_PREDICATE_HPP_JOFA_101102
  9. #define BOOST_ICL_TYPE_TRAITS_PREDICATE_HPP_JOFA_101102
  10. namespace boost{namespace icl
  11. {
  12. // naming convention
  13. // predicate: n-ary predicate
  14. // property: unary predicate
  15. // relation: binary predicate
  16. // Unary predicates
  17. template <class Type>
  18. class property
  19. {
  20. public:
  21. typedef Type argument_type;
  22. typedef bool result_type;
  23. };
  24. template <class Type>
  25. class member_property : public property<Type>
  26. {
  27. public:
  28. member_property( bool(Type::* pred)()const ): property<Type>(), m_pred(pred){}
  29. bool operator()(const Type& x)const { return (x.*m_pred)(); }
  30. private:
  31. bool(Type::* m_pred)()const;
  32. } ;
  33. // Binary predicates: relations
  34. template <class LeftT, class RightT>
  35. class relation
  36. {
  37. public:
  38. typedef LeftT first_argument_type;
  39. typedef RightT second_argument_type;
  40. typedef bool result_type;
  41. };
  42. }} // namespace icl boost
  43. #endif