interval_traits.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_INTERVAL_TRAITS_HPP_JOFA_100926
  9. #define BOOST_ICL_INTERVAL_TRAITS_HPP_JOFA_100926
  10. #include <boost/icl/type_traits/domain_type_of.hpp>
  11. #include <boost/icl/type_traits/difference_type_of.hpp>
  12. #include <boost/icl/type_traits/size_type_of.hpp>
  13. namespace boost{ namespace icl
  14. {
  15. template<class Type> struct interval_traits;
  16. template<class Type>
  17. struct domain_type_of<interval_traits<Type> >
  18. {
  19. typedef typename interval_traits<Type>::domain_type type;
  20. };
  21. //------------------------------------------------------------------------------
  22. //- Adapter class
  23. //------------------------------------------------------------------------------
  24. template<class Type> struct interval_traits
  25. {
  26. typedef interval_traits type;
  27. typedef typename domain_type_of<Type>::type domain_type;
  28. static Type construct(const domain_type& lo, const domain_type& up);
  29. static domain_type upper(const Type& inter_val);
  30. static domain_type lower(const Type& inter_val);
  31. };
  32. template<class Type>
  33. struct difference_type_of<interval_traits<Type> >
  34. {
  35. typedef typename interval_traits<Type>::domain_type domain_type;
  36. typedef typename difference_type_of<domain_type>::type type;
  37. };
  38. template<class Type>
  39. struct size_type_of<interval_traits<Type> >
  40. {
  41. typedef typename interval_traits<Type>::domain_type domain_type;
  42. typedef typename size_type_of<domain_type>::type type;
  43. };
  44. }} // namespace boost icl
  45. #endif