Back to home page

EIC code displayed by LXR

 
 

    


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

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 container_adaptor/map_adaptor.hpp
0010 /// \brief Container adaptor to easily build a std::map signature compatible container.
0011 
0012 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_MAP_ADAPTOR_HPP
0013 #define BOOST_BIMAP_CONTAINER_ADAPTOR_MAP_ADAPTOR_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #include <boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp>
0022 #include <boost/mpl/vector.hpp>
0023 #include <boost/mpl/aux_/na.hpp>
0024 #include <boost/call_traits.hpp>
0025 
0026 namespace boost {
0027 namespace bimaps {
0028 namespace container_adaptor {
0029 
0030 /// \brief Container adaptor to easily build a std::map signature compatible container.
0031 
0032 template
0033 <
0034     class Base,
0035 
0036     class Iterator,
0037     class ConstIterator,
0038     class ReverseIterator,
0039     class ConstReverseIterator,
0040 
0041     class IteratorToBaseConverter          = ::boost::mpl::na,
0042     class IteratorFromBaseConverter        = ::boost::mpl::na,
0043     class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
0044     class ValueToBaseConverter             = ::boost::mpl::na,
0045     class ValueFromBaseConverter           = ::boost::mpl::na,
0046     class KeyToBaseConverter               = ::boost::mpl::na,
0047 
0048     class FunctorsFromDerivedClasses = mpl::vector<>
0049 >
0050 class map_adaptor :
0051 
0052     public ::boost::bimaps::container_adaptor::
0053                 ordered_associative_container_adaptor
0054     <
0055         Base,
0056         Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0057         BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
0058         IteratorToBaseConverter, IteratorFromBaseConverter,
0059         ReverseIteratorFromBaseConverter,
0060         ValueToBaseConverter, ValueFromBaseConverter,
0061         KeyToBaseConverter,
0062         FunctorsFromDerivedClasses
0063     >
0064 {
0065 
0066     typedef ::boost::bimaps::container_adaptor::
0067                 ordered_associative_container_adaptor
0068     <
0069         Base,
0070         Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0071         BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
0072         IteratorToBaseConverter, IteratorFromBaseConverter,
0073         ReverseIteratorFromBaseConverter,
0074         ValueToBaseConverter, ValueFromBaseConverter,
0075         KeyToBaseConverter,
0076         FunctorsFromDerivedClasses
0077 
0078     > base_;
0079 
0080     // MetaData -------------------------------------------------------------
0081 
0082     public:
0083 
0084     typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
0085     typedef data_type mapped_type;
0086 
0087     // Access -----------------------------------------------------------------
0088 
0089     public:
0090 
0091     explicit map_adaptor(Base & c) :
0092         base_(c) {}
0093 
0094     protected:
0095 
0096     typedef map_adaptor map_adaptor_;
0097 
0098     // Interface --------------------------------------------------------------
0099 
0100     public:
0101 
0102     template< class CompatibleKey >
0103     data_type& operator[](const CompatibleKey & k)
0104     {
0105         return this->base()
0106             [this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)];
0107     }
0108 
0109     template< class CompatibleKey >
0110     data_type& at(const CompatibleKey & k)
0111     {
0112         return this->base().
0113             at(this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k));
0114     }
0115 
0116     template< class CompatibleKey >
0117     const data_type& at(const CompatibleKey & k) const
0118     {
0119         return this->base().
0120             at(this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k));
0121     }
0122 
0123 };
0124 
0125 
0126 } // namespace container_adaptor
0127 } // namespace bimaps
0128 } // namespace boost
0129 
0130 
0131 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_MAP_ADAPTOR_HPP
0132