/*-----------------------------------------------------------------------------+ Copyright (c) 2008-2009: Joachim Faulhaber +------------------------------------------------------------------------------+ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENCE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-----------------------------------------------------------------------------*/ #ifndef BOOST_ICL_TYPE_TRAITS_DIFFERENCE_TYPE_OF_HPP_JOFA_080911 #define BOOST_ICL_TYPE_TRAITS_DIFFERENCE_TYPE_OF_HPP_JOFA_080911 #include // For macro BOOST_STATIC_CONSTANT #include #include #include #include #include #include #include #include namespace boost{ namespace icl { namespace detail { BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type) } //-------------------------------------------------------------------------- template struct has_difference_type : mpl::bool_::value> {}; //-------------------------------------------------------------------------- template // type_of(T-T)==T struct is_subtraction_closed { typedef is_subtraction_closed type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_< is_numeric , mpl::and_< has_rep_type , mpl::not_ > > >::value) ); }; //-------------------------------------------------------------------------- template struct has_difference { typedef has_difference type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_< is_subtraction_closed , is_pointer , has_difference_type >::value) ); }; //-------------------------------------------------------------------------- template struct get_difference_type; template struct get_difference_type { typedef no_type type; }; template struct get_difference_type { typedef std::ptrdiff_t type; }; template struct get_difference_type { typedef Type type; }; template struct get_difference_type { typedef typename Type::difference_type type; }; //-------------------------------------------------------------------------- template struct difference_type_of { typedef typename get_difference_type< Type , has_difference::value , has_difference_type::value >::type type; }; }} // namespace boost icl #endif