Boost C++ Libraries Boost.Bimap Home Libraries People FAQ More

PrevUpHomeNext

manage_bimap_key.hpp

Go to the documentation of this file.
00001 // Boost.Bimap
00002 //
00003 // Copyright (c) 2006-2007 Matias Capeletto
00004 //
00005 // Distributed under the Boost Software License, Version 1.0.
00006 // (See accompanying file LICENSE_1_0.txt or copy at
00007 // http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 /// \file detail/manage_bimap_key.hpp
00010 /// \brief Utility class to manage the set types of a bimap.
00011 
00012 #ifndef BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP
00013 #define BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP
00014 
00015 #if defined(_MSC_VER) && (_MSC_VER>=1200)
00016 #pragma once
00017 #endif
00018 
00019 #include <boost/config.hpp>
00020 
00021 // Boost.Bimap.Tags
00022 #include <boost/bimap/tags/support/default_tagged.hpp>
00023 #include <boost/bimap/tags/support/apply_to_value_type.hpp>
00024 
00025 // Boost.MPL
00026 #include <boost/mpl/if.hpp>
00027 #include <boost/mpl/placeholders.hpp>
00028 
00029 #include <boost/bimap/detail/is_set_type_of.hpp>
00030 
00031 #include <boost/bimap/set_of.hpp>
00032 
00033 
00034 namespace boost {
00035 namespace bimaps {
00036 namespace detail {
00037 
00038 /** \struct boost::bimaps::detail::manage_bimap_key
00039 \brief Metafunction to manage the set types of a bimap.
00040 
00041 \code
00042 template< class SetType, class DefaultTag >
00043 struct manage_bimap_key
00044 {
00045     typedef {TaggedSetType} type;
00046 }
00047 \endcode
00048 
00049 If KeyType is not tagged, DefaultTag is used. If KeyType is not a SetOfType
00050 specification it is converted to set_of< value_type_of<KeyType>::type > and the
00051 it is tagged with his tag or the default one.
00052 
00053 See also bimap, bimap_core.
00054                                                                                 **/
00055 
00056 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
00057 
00058 template< class SetType, class DefaultTag >
00059 struct manage_bimap_key
00060 {
00061     // First, convert the type to a tagged one with the default tag
00062 
00063     typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged
00064     <
00065         SetType, DefaultTag
00066 
00067     >::type tagged_set_type;
00068 
00069     // Then manage plain key types, were the set type of the collection
00070     // is not specified in the instantiation
00071 
00072     typedef BOOST_DEDUCED_TYPENAME
00073 
00074        mpl::if_< BOOST_DEDUCED_TYPENAME is_set_type_of<
00075                     BOOST_DEDUCED_TYPENAME tagged_set_type::value_type >::type,
00076     // {
00077             // The type is
00078             tagged_set_type,
00079     // }
00080     // else
00081     // {
00082             // Default it to a set
00083             BOOST_DEDUCED_TYPENAME tags::support::apply_to_value_type
00084             <
00085                 set_of< mpl::_ >,
00086                 tagged_set_type
00087 
00088             >::type
00089     // }
00090 
00091     >::type type;
00092 };
00093 
00094 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
00095 
00096 } // namespace detail
00097 } // namespace bimaps
00098 } // namespace boost
00099 
00100 
00101 #endif // BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP
00102 
00103 
Copyright 2006 Matias Capeletto

PrevUpHomeNext