on_absorbtion.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_ON_ABSORBTION_HPP_JOFA_100915
  9. #define BOOST_ICL_TYPE_TRAITS_ON_ABSORBTION_HPP_JOFA_100915
  10. namespace boost{ namespace icl
  11. {
  12. template<class Type, class Combiner, bool absorbs_identities>
  13. struct on_absorbtion;
  14. template<class Type, class Combiner>
  15. struct on_absorbtion<Type, Combiner, false>
  16. {
  17. typedef on_absorbtion type;
  18. typedef typename Type::codomain_type codomain_type;
  19. static bool is_absorbable(const codomain_type&){ return false; }
  20. };
  21. template<class Type, class Combiner>
  22. struct on_absorbtion<Type, Combiner, true>
  23. {
  24. typedef on_absorbtion type;
  25. typedef typename Type::codomain_type codomain_type;
  26. typedef typename Type::codomain_combine codomain_combine;
  27. static bool is_absorbable(const codomain_type& co_value)
  28. {
  29. return co_value == Combiner::identity_element();
  30. }
  31. };
  32. }} // namespace boost icl
  33. #endif