sub_super_set.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_PREDICATES_SUB_SUPER_SET_HPP_JOFA_101102
  9. #define BOOST_ICL_PREDICATES_SUB_SUPER_SET_HPP_JOFA_101102
  10. #include <boost/icl/type_traits/predicate.hpp>
  11. #include <boost/icl/type_traits/type_to_string.hpp>
  12. namespace boost{namespace icl
  13. {
  14. /// Functor class template contained_in implements the subset relation.
  15. template<class Type>
  16. struct sub_super_set : public relation<Type,Type>
  17. {
  18. /// Apply the subset relation.
  19. /** <tt>contained_in(sub, super)</tt> is true if <tt>sub</tt>
  20. is contained in <tt>super</tt> */
  21. bool operator()(const Type& sub, const Type& super)const
  22. {
  23. return contains(super, sub);
  24. }
  25. };
  26. template<>
  27. inline std::string unary_template_to_string<icl::sub_super_set>::apply()
  28. { return "C="; }
  29. /// Functor class template <b>contains</b> implements the superset relation.
  30. template<class Type>
  31. struct super_sub_set : public relation<Type,Type>
  32. {
  33. /// Apply the superset relation.
  34. /** <tt>contains(super, sub)</tt> is true if <tt>super</tt> containes
  35. <tt>sub</tt> */
  36. bool operator()(const Type& super, const Type& sub)const
  37. {
  38. return contains(super, sub);
  39. }
  40. };
  41. template<>
  42. inline std::string unary_template_to_string<icl::super_sub_set>::apply()
  43. { return "D="; }
  44. }} // namespace icl boost
  45. #endif