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