Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:38

0001 // Boost.Bimap
0002 //
0003 // Copyright (c) 2006-2007 Matias Capeletto
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 /// \file detail/manage_additional_parameters.hpp
0010 /// \brief Utility class to extract the additional parameters from the template parameters.
0011 
0012 #ifndef BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
0013 #define BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #include <memory>
0022 
0023 // Boost.MPL
0024 #include <boost/mpl/bool.hpp>
0025 #include <boost/mpl/if.hpp>
0026 #include <boost/mpl/aux_/na.hpp>
0027 #include <boost/type_traits/is_same.hpp>
0028 
0029 #include <boost/bimap/detail/is_set_type_of.hpp>
0030 
0031 namespace boost {
0032 namespace bimaps {
0033 
0034 template< class Type >
0035 struct with_info
0036 {
0037     typedef Type value_type;
0038 };
0039 
0040 namespace detail {
0041 
0042 /// \brief Metafunction to check if a given type is a data_hook specification.
0043 
0044 template< class Type >
0045 struct is_with_info : ::boost::mpl::false_ {};
0046 
0047 template< class ValueType >
0048 struct is_with_info< with_info<ValueType> > : ::boost::mpl::true_ {};
0049 
0050 /** \struct boost::bimaps::detail::manage_additional_parameters
0051 \brief Utility class to extract the additional parameters from the template parameters.
0052 
0053 \code
0054 template< class AP1, class AP2, class AP3 >
0055 struct manage_additional_parameters
0056 {
0057     struct parameters
0058     {
0059         typedef -unspecified- set_type_of_relation;
0060         typedef -unspecified- data_hook;
0061         typedef -unspecified- allocator;
0062     };
0063 
0064     typedef parameters type;
0065 };
0066 \endcode
0067 
0068 See also bimap, bimap_core.
0069                                                                                 **/
0070 
0071 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0072 
0073 template< class AP1, class AP2, class AP3 >
0074 struct manage_additional_parameters
0075 {
0076     // (1) manage_additional_parameters<
0077     //         not_specified,not_specified,not_specified>
0078     //
0079     //     set_type_of_relation: based on the left key type
0080     //     info_hook:            no additional info
0081     //     allocator:            default allocator
0082 
0083     struct case_NNN
0084     {
0085         typedef left_based set_type_of_relation;
0086         typedef std::allocator<char> allocator;
0087         typedef ::boost::mpl::na additional_info;
0088     };
0089 
0090     // (2) manage_additional_parameters<Allocator,not_specified,not_specified>
0091     //
0092     //     set_type_of_relation: based on the left key type
0093     //     info_hook:            no additional info
0094     //     allocator:            Allocator
0095 
0096     struct case_ANN
0097     {
0098         typedef left_based set_type_of_relation;
0099         typedef AP1 allocator;
0100         typedef ::boost::mpl::na additional_info;
0101     };
0102 
0103     // (3) manage_additional_parameters<
0104     //         SetOfRelationType,not_specified,not_specified>
0105     //
0106     //     set_type_of_relation: SetTypeOfRelation
0107     //     info_hook:            no additional info
0108     //     allocator:            default allocator
0109 
0110     struct case_SNN
0111     {
0112         typedef AP1 set_type_of_relation;
0113         typedef std::allocator<char> allocator;
0114         typedef ::boost::mpl::na additional_info;
0115     };
0116 
0117     // (4) manage_additional_parameters<
0118     //          SetTypeOfRelation,Allocator,not_specified>
0119     //
0120     //     set_type_of_relation: SetTypeOfRelation
0121     //     info_hook:            no additional info
0122     //     allocator:            Allocator
0123 
0124     struct case_SAN
0125     {
0126         typedef AP1 set_type_of_relation;
0127         typedef AP2 allocator;
0128         typedef ::boost::mpl::na additional_info;
0129     };
0130 
0131     // (5) manage_additional_parameters<InfoToHook,not_specified,not_specified>
0132     //
0133     //     set_type_of_relation: based on the left key type
0134     //     info_hook:            InfoToHook
0135     //     allocator:            default allocator
0136 
0137     struct case_HNN
0138     {
0139         typedef left_based set_type_of_relation;
0140         typedef std::allocator<char> allocator;
0141         typedef BOOST_DEDUCED_TYPENAME AP1::value_type additional_info;
0142     };
0143 
0144     // (6) manage_additional_parameters<
0145     //         SetTypeOfRelation,InfoToHook,not_specified>
0146     //
0147     //     set_type_of_relation: SetTypeOfRelation
0148     //     info_hook:            InfoToHook
0149     //     allocator:            default allocator
0150 
0151     struct case_SHN
0152     {
0153         typedef AP1 set_type_of_relation;
0154         typedef std::allocator<char> allocator;
0155         typedef BOOST_DEDUCED_TYPENAME AP2::value_type additional_info;
0156     };
0157 
0158     // (7) manage_additional_parameters<
0159     //         DataToHook,Allocator,not_specified>
0160     //
0161     //     set_type_of_relation: SetTypeOfRelation
0162     //     info_hook:            InfoToHook
0163     //     allocator:            default allocator
0164 
0165     struct case_HAN
0166     {
0167         typedef left_based set_type_of_relation;
0168         typedef AP2 allocator;
0169         typedef BOOST_DEDUCED_TYPENAME AP1::value_type additional_info;
0170     };
0171 
0172     // (8) manage_additional_parameters<
0173     //         SetTypeOfRelation,DataToHook,Allocator>
0174     //
0175     //     set_type_of_relation: SetTypeOfRelation
0176     //     info_hook:            InfoToHook
0177     //     allocator:            Allocator
0178 
0179     struct case_SHA
0180     {
0181         typedef AP1 set_type_of_relation;
0182         typedef AP2 allocator;
0183         typedef BOOST_DEDUCED_TYPENAME AP2::value_type additional_info;
0184     };
0185 
0186     // Some annidated mpl::if_ and we are done!
0187 
0188     typedef BOOST_DEDUCED_TYPENAME mpl::if_
0189     <
0190         ::boost::mpl::is_na<AP1>,
0191         case_NNN, // (1)
0192         BOOST_DEDUCED_TYPENAME mpl::if_
0193         <
0194             ::boost::mpl::is_na<AP2>,
0195             BOOST_DEDUCED_TYPENAME mpl::if_
0196             <
0197                 is_set_type_of_relation<AP1>,
0198                 case_SNN, // (3)
0199                 BOOST_DEDUCED_TYPENAME mpl::if_
0200                 <
0201                     is_with_info<AP1>,
0202                     case_HNN, // (5)
0203                     case_ANN  // (2)
0204 
0205                 >::type
0206 
0207             >::type,
0208             BOOST_DEDUCED_TYPENAME mpl::if_
0209             <
0210                 ::boost::mpl::is_na<AP3>,
0211                 BOOST_DEDUCED_TYPENAME mpl::if_
0212                 <
0213                     is_with_info<AP1>,
0214                     case_HAN, // (7)
0215                     BOOST_DEDUCED_TYPENAME mpl::if_
0216                     <
0217                         is_with_info<AP2>,
0218                         case_SHN, // (6)
0219                         case_SAN  // (4)
0220 
0221                     >::type
0222 
0223                 >::type,
0224 
0225                 case_SHA // (8)
0226 
0227             >::type
0228 
0229         >::type
0230 
0231     >::type type;
0232 
0233 };
0234 
0235 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0236 
0237 } // namespace detail
0238 } // namespace bimaps
0239 } // namespace boost
0240 
0241 
0242 #endif // BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
0243