Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:07

0001 /* Copyright 2003-2013 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/multi_index for library home page.
0007  */
0008 
0009 #ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_ARGS_HPP
0010 #define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_ARGS_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
0017 #include <boost/mpl/aux_/na.hpp>
0018 #include <boost/mpl/eval_if.hpp>
0019 #include <boost/mpl/identity.hpp>
0020 #include <boost/mpl/if.hpp>
0021 #include <boost/multi_index/tag.hpp>
0022 #include <boost/static_assert.hpp>
0023 #include <boost/type_traits/is_same.hpp>
0024 #include <functional>
0025 
0026 namespace boost{
0027 
0028 namespace multi_index{
0029 
0030 namespace detail{
0031 
0032 /* Oredered index specifiers can be instantiated in two forms:
0033  *
0034  *   (ordered_unique|ordered_non_unique)<
0035  *     KeyFromValue,Compare=std::less<KeyFromValue::result_type> >
0036  *   (ordered_unique|ordered_non_unique)<
0037  *     TagList,KeyFromValue,Compare=std::less<KeyFromValue::result_type> >
0038  *
0039  * index_args implements the machinery to accept this argument-dependent
0040  * polymorphism.
0041  */
0042 
0043 template<typename KeyFromValue>
0044 struct index_args_default_compare
0045 {
0046   typedef std::less<typename KeyFromValue::result_type> type;
0047 };
0048 
0049 template<typename Arg1,typename Arg2,typename Arg3>
0050 struct ordered_index_args
0051 {
0052   typedef is_tag<Arg1> full_form;
0053 
0054   typedef typename mpl::if_<
0055     full_form,
0056     Arg1,
0057     tag< > >::type                                   tag_list_type;
0058   typedef typename mpl::if_<
0059     full_form,
0060     Arg2,
0061     Arg1>::type                                      key_from_value_type;
0062   typedef typename mpl::if_<
0063     full_form,
0064     Arg3,
0065     Arg2>::type                                      supplied_compare_type;
0066   typedef typename mpl::eval_if<
0067     mpl::is_na<supplied_compare_type>,
0068     index_args_default_compare<key_from_value_type>,
0069     mpl::identity<supplied_compare_type>
0070   >::type                                            compare_type;
0071 
0072   BOOST_STATIC_ASSERT(is_tag<tag_list_type>::value);
0073   BOOST_STATIC_ASSERT(!mpl::is_na<key_from_value_type>::value);
0074   BOOST_STATIC_ASSERT(!mpl::is_na<compare_type>::value);
0075 };
0076 
0077 } /* namespace multi_index::detail */
0078 
0079 } /* namespace multi_index */
0080 
0081 } /* namespace boost */
0082 
0083 #endif