[857] | 1 | /* Copyright 2003-2005 Joaquín M López Muñoz.
|
---|
| 2 | * Distributed under the Boost Software License, Version 1.0.
|
---|
| 3 | * (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 4 | * http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 5 | *
|
---|
| 6 | * See http://www.boost.org/libs/multi_index for library home page.
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | #ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_ARGS_HPP
|
---|
| 10 | #define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_ARGS_HPP
|
---|
| 11 |
|
---|
| 12 | #if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
---|
| 13 | #pragma once
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
---|
| 17 | #include <boost/mpl/aux_/na.hpp>
|
---|
| 18 | #include <boost/mpl/eval_if.hpp>
|
---|
| 19 | #include <boost/mpl/identity.hpp>
|
---|
| 20 | #include <boost/mpl/if.hpp>
|
---|
| 21 | #include <boost/multi_index/tag.hpp>
|
---|
| 22 | #include <boost/static_assert.hpp>
|
---|
| 23 | #include <boost/type_traits/is_same.hpp>
|
---|
| 24 | #include <functional>
|
---|
| 25 |
|
---|
| 26 | namespace boost{
|
---|
| 27 |
|
---|
| 28 | namespace multi_index{
|
---|
| 29 |
|
---|
| 30 | namespace detail{
|
---|
| 31 |
|
---|
| 32 | /* Oredered index specifiers can be instantiated in two forms:
|
---|
| 33 | *
|
---|
| 34 | * (ordered_unique|ordered_non_unique)<
|
---|
| 35 | * KeyFromValue,Compare=std::less<KeyFromValue::result_type> >
|
---|
| 36 | * (ordered_unique|ordered_non_unique)<
|
---|
| 37 | * TagList,KeyFromValue,Compare=std::less<KeyFromValue::result_type> >
|
---|
| 38 | *
|
---|
| 39 | * index_args implements the machinery to accept this argument-dependent
|
---|
| 40 | * polymorphism.
|
---|
| 41 | */
|
---|
| 42 |
|
---|
| 43 | template<typename KeyFromValue>
|
---|
| 44 | struct index_args_default_compare
|
---|
| 45 | {
|
---|
| 46 | typedef std::less<typename KeyFromValue::result_type> type;
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | template<typename Arg1,typename Arg2,typename Arg3>
|
---|
| 50 | struct ordered_index_args
|
---|
| 51 | {
|
---|
| 52 | typedef is_tag<Arg1> full_form;
|
---|
| 53 |
|
---|
| 54 | typedef typename mpl::if_<
|
---|
| 55 | full_form,
|
---|
| 56 | Arg1,
|
---|
| 57 | tag< > >::type tag_list_type;
|
---|
| 58 | typedef typename mpl::if_<
|
---|
| 59 | full_form,
|
---|
| 60 | Arg2,
|
---|
| 61 | Arg1>::type key_from_value_type;
|
---|
| 62 | typedef typename mpl::if_<
|
---|
| 63 | full_form,
|
---|
| 64 | Arg3,
|
---|
| 65 | Arg2>::type supplied_compare_type;
|
---|
| 66 | typedef typename mpl::eval_if<
|
---|
| 67 | mpl::is_na<supplied_compare_type>,
|
---|
| 68 | index_args_default_compare<key_from_value_type>,
|
---|
| 69 | mpl::identity<supplied_compare_type>
|
---|
| 70 | >::type compare_type;
|
---|
| 71 |
|
---|
| 72 | BOOST_STATIC_ASSERT(is_tag<tag_list_type>::value);
|
---|
| 73 | BOOST_STATIC_ASSERT(!mpl::is_na<key_from_value_type>::value);
|
---|
| 74 | BOOST_STATIC_ASSERT(!mpl::is_na<compare_type>::value);
|
---|
| 75 | };
|
---|
| 76 |
|
---|
| 77 | } /* namespace multi_index::detail */
|
---|
| 78 |
|
---|
| 79 | } /* namespace multi_index */
|
---|
| 80 |
|
---|
| 81 | } /* namespace boost */
|
---|
| 82 |
|
---|
| 83 | #endif
|
---|