Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /* Copyright 2003-2022 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_HASH_INDEX_ARGS_HPP
0010 #define BOOST_MULTI_INDEX_DETAIL_HASH_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/container_hash/hash.hpp>
0018 #include <boost/mpl/aux_/na.hpp>
0019 #include <boost/mpl/eval_if.hpp>
0020 #include <boost/mpl/identity.hpp>
0021 #include <boost/mpl/if.hpp>
0022 #include <boost/multi_index/tag.hpp>
0023 #include <boost/static_assert.hpp>
0024 #include <boost/type_traits/is_same.hpp>
0025 #include <functional>
0026 
0027 namespace boost{
0028 
0029 namespace multi_index{
0030 
0031 namespace detail{
0032 
0033 /* Hashed index specifiers can be instantiated in two forms:
0034  *
0035  *   (hashed_unique|hashed_non_unique)<
0036  *     KeyFromValue,
0037  *     Hash=boost::hash<KeyFromValue::result_type>,
0038  *     Pred=std::equal_to<KeyFromValue::result_type> >
0039  *   (hashed_unique|hashed_non_unique)<
0040  *     TagList,
0041  *     KeyFromValue,
0042  *     Hash=boost::hash<KeyFromValue::result_type>,
0043  *     Pred=std::equal_to<KeyFromValue::result_type> >
0044  *
0045  * hashed_index_args implements the machinery to accept this
0046  * argument-dependent polymorphism.
0047  */
0048 
0049 template<typename KeyFromValue>
0050 struct index_args_default_hash
0051 {
0052   typedef ::boost::hash<typename KeyFromValue::result_type> type;
0053 };
0054 
0055 template<typename KeyFromValue>
0056 struct index_args_default_pred
0057 {
0058   typedef std::equal_to<typename KeyFromValue::result_type> type;
0059 };
0060 
0061 template<typename Arg1,typename Arg2,typename Arg3,typename Arg4>
0062 struct hashed_index_args
0063 {
0064   typedef is_tag<Arg1> full_form;
0065 
0066   typedef typename mpl::if_<
0067     full_form,
0068     Arg1,
0069     tag< > >::type                                   tag_list_type;
0070   typedef typename mpl::if_<
0071     full_form,
0072     Arg2,
0073     Arg1>::type                                      key_from_value_type;
0074   typedef typename mpl::if_<
0075     full_form,
0076     Arg3,
0077     Arg2>::type                                      supplied_hash_type;
0078   typedef typename mpl::eval_if<
0079     mpl::is_na<supplied_hash_type>,
0080     index_args_default_hash<key_from_value_type>,
0081     mpl::identity<supplied_hash_type>
0082   >::type                                            hash_type;
0083   typedef typename mpl::if_<
0084     full_form,
0085     Arg4,
0086     Arg3>::type                                      supplied_pred_type;
0087   typedef typename mpl::eval_if<
0088     mpl::is_na<supplied_pred_type>,
0089     index_args_default_pred<key_from_value_type>,
0090     mpl::identity<supplied_pred_type>
0091   >::type                                            pred_type;
0092 
0093   BOOST_STATIC_ASSERT(is_tag<tag_list_type>::value);
0094   BOOST_STATIC_ASSERT(!mpl::is_na<key_from_value_type>::value);
0095   BOOST_STATIC_ASSERT(!mpl::is_na<hash_type>::value);
0096   BOOST_STATIC_ASSERT(!mpl::is_na<pred_type>::value);
0097 };
0098 
0099 } /* namespace multi_index::detail */
0100 
0101 } /* namespace multi_index */
0102 
0103 } /* namespace boost */
0104 
0105 #endif