/*-----------------------------------------------------------------------------+ 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_IS_COMBINABLE_HPP_JOFA_090115 #define BOOST_ICL_IS_COMBINABLE_HPP_JOFA_090115 #include #include #include #include #include #include #include #include namespace boost{namespace icl { template struct is_overloadable { typedef is_overloadable type; BOOST_STATIC_CONSTANT(bool, value = (boost::is_same::value) ); }; //------------------------------------------------------------------------------ template struct is_codomain_equal { typedef is_codomain_equal type; BOOST_STATIC_CONSTANT(bool, value = (boost::is_same::value) ); }; //NOTE: Equality of compare order implies the equality of the domain_types template struct is_key_compare_equal { typedef is_key_compare_equal type; BOOST_STATIC_CONSTANT(bool, value = (boost::is_same::value) ); }; template struct is_codomain_type_equal { typedef is_codomain_type_equal type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_, is_codomain_equal >::value) ); }; // For equal containers concepts, domain order and codomain type must match. templateclass IsConcept, class LeftT, class RightT> struct is_concept_compatible { typedef is_concept_compatible type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_< IsConcept , IsConcept , is_codomain_type_equal >::value) ); }; templateclass LeftConcept, templateclass RightConcept, class LeftT, class RightT> struct is_concept_combinable { typedef is_concept_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_< LeftConcept , RightConcept , is_key_compare_equal >::value) ); }; template struct is_intra_combinable { typedef is_intra_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_< is_concept_compatible , is_concept_compatible >::value) ); }; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ template struct is_cross_combinable { typedef is_cross_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_< is_concept_combinable , is_concept_combinable >::value) ); }; template struct is_inter_combinable { typedef is_inter_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_, is_cross_combinable >::value) ); }; //------------------------------------------------------------------------------ // is_fragment_of //------------------------------------------------------------------------------ template struct is_fragment_of { typedef is_fragment_of type; BOOST_STATIC_CONSTANT(bool, value = false); }; template struct is_fragment_of { typedef is_fragment_of type; BOOST_STATIC_CONSTANT(bool, value = true); }; template struct is_fragment_of { typedef is_fragment_of type; BOOST_STATIC_CONSTANT(bool, value = true); }; //------------------------------------------------------------------------------ // is_key_of //------------------------------------------------------------------------------ template struct is_key_of { typedef is_key_of type; BOOST_STATIC_CONSTANT(bool, value = false); }; template struct is_key_of { typedef is_key_of type; BOOST_STATIC_CONSTANT(bool, value = true); }; template struct is_key_of { typedef is_key_of type; BOOST_STATIC_CONSTANT(bool, value = true); }; //------------------------------------------------------------------------------ // is_interval_set_derivative //------------------------------------------------------------------------------ template struct is_interval_set_derivative; template struct is_interval_set_derivative { typedef is_interval_set_derivative type; BOOST_STATIC_CONSTANT(bool, value = (is_interval_container::value)); }; template struct is_interval_set_derivative { typedef is_interval_set_derivative type; BOOST_STATIC_CONSTANT(bool, value = (is_interval_container::value)); }; template struct is_interval_set_derivative { typedef is_interval_set_derivative type; BOOST_STATIC_CONSTANT(bool, value = false); }; //------------------------------------------------------------------------------ // is_interval_map_derivative //------------------------------------------------------------------------------ template struct is_interval_map_derivative; template struct is_interval_map_derivative { typedef is_interval_map_derivative type; BOOST_STATIC_CONSTANT(bool, value = (is_interval_container::value)); }; template struct is_interval_map_derivative { typedef is_interval_map_derivative type; BOOST_STATIC_CONSTANT(bool, value = (is_interval_container::value)); }; template struct is_interval_map_derivative { typedef is_interval_map_derivative type; BOOST_STATIC_CONSTANT(bool, value = (is_interval_container::value)); }; template struct is_interval_map_derivative { typedef is_interval_map_derivative type; BOOST_STATIC_CONSTANT(bool, value = false); }; //------------------------------------------------------------------------------ // is_intra_derivative //------------------------------------------------------------------------------ template struct is_intra_derivative { typedef is_intra_derivative type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_ < mpl::and_, is_interval_set_derivative > , mpl::and_, is_interval_map_derivative > >::value) ); }; template struct is_cross_derivative { typedef is_cross_derivative type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_< is_interval_map , is_interval_set_derivative >::value) ); }; template struct is_inter_derivative { typedef is_inter_derivative type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_< is_intra_derivative , is_cross_derivative >::value) ); }; //------------------------------------------------------------------------------ //- right combinable //------------------------------------------------------------------------------ template struct is_interval_set_right_combinable { typedef is_interval_set_right_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_ < is_interval_set , mpl::or_ < is_interval_set_derivative , is_concept_compatible > >::value) ); }; template struct is_interval_map_right_intra_combinable //NOTE equivalent to is_fragment_type_of { typedef is_interval_map_right_intra_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_ < is_interval_map , mpl::or_ < is_interval_map_derivative , is_concept_compatible > >::value) ); }; template struct is_interval_map_right_cross_combinable //NOTE equivalent to key_type_of { typedef is_interval_map_right_cross_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_ < is_interval_map , mpl::or_ < is_cross_derivative , is_concept_combinable > >::value) ); }; template struct is_interval_map_right_inter_combinable { typedef is_interval_map_right_inter_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_< is_interval_map_right_intra_combinable , is_interval_map_right_cross_combinable >::value) ); }; template struct is_right_intra_combinable { typedef is_right_intra_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_ < is_interval_set_right_combinable , is_interval_map_right_intra_combinable >::value) ); }; template struct is_right_inter_combinable { typedef is_right_inter_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_ < is_interval_set_right_combinable , is_interval_map_right_inter_combinable >::value) ); }; template struct combines_right_to_interval_set { typedef combines_right_to_interval_set type; BOOST_STATIC_CONSTANT(bool, value = (is_concept_combinable::value) ); }; template struct combines_right_to_interval_map { typedef combines_right_to_interval_map type; BOOST_STATIC_CONSTANT(bool, value = (is_concept_compatible::value) ); }; template struct combines_right_to_interval_container { typedef combines_right_to_interval_container type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_, combines_right_to_interval_map >::value) ); }; //------------------------------------------------------------------------------ //- segmentational_fineness //------------------------------------------------------------------------------ template struct unknown_fineness { typedef unknown_fineness type; static const int value = 0; }; template struct known_fineness { typedef known_fineness type; static const int value = Type::fineness; }; templatestruct segmentational_fineness { typedef segmentational_fineness type; static const int value = mpl::if_, known_fineness, unknown_fineness >::type::value; }; //------------------------------------------------------------------------------ // is_interval_set_companion //------------------------------------------------------------------------------ // CompanionT is either an interval_set or a derivative of set level: // element_type=domain_type, segment_type=interval_type template struct is_interval_set_companion { typedef is_interval_set_companion type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_ < combines_right_to_interval_set , is_interval_set_derivative >::value) ); }; //------------------------------------------------------------------------------ // is_interval_map_companion //------------------------------------------------------------------------------ template struct is_interval_map_companion { typedef is_interval_map_companion type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_ < combines_right_to_interval_map , is_interval_map_derivative >::value) ); }; //------------------------------------------------------------------------------ //- is_coarser_interval_{set,map}_companion //------------------------------------------------------------------------------ template struct is_coarser_interval_set_companion { typedef is_coarser_interval_set_companion type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_ < is_interval_set_companion , mpl::bool_<( segmentational_fineness::value > segmentational_fineness::value)> >::value) ); }; template struct is_coarser_interval_map_companion { typedef is_coarser_interval_map_companion type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_ < is_interval_map_companion , mpl::bool_<( segmentational_fineness::value > segmentational_fineness::value)> >::value) ); }; //------------------------------------------------------------------------------ // is_binary_interval_{set,map}_combinable //------------------------------------------------------------------------------ template struct is_binary_interval_set_combinable { typedef is_binary_interval_set_combinable type; static const int value = mpl::and_< is_interval_set , is_coarser_interval_set_companion >::value; }; template struct is_binary_interval_map_combinable { typedef is_binary_interval_map_combinable type; static const int value = mpl::and_< is_interval_map , is_coarser_interval_map_companion >::value; }; template struct is_binary_intra_combinable { typedef is_binary_intra_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_, is_binary_interval_map_combinable >::value) ); }; template struct is_binary_cross_combinable { typedef is_binary_cross_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::and_ < is_interval_map , mpl::or_< is_coarser_interval_map_companion , is_interval_set_companion > >::value) ); }; template struct is_binary_inter_combinable { typedef is_binary_inter_combinable type; BOOST_STATIC_CONSTANT(bool, value = (mpl::or_ < mpl::and_, is_binary_cross_combinable > , mpl::and_, is_binary_intra_combinable > >::value) ); }; }} // namespace icl boost #endif