3 // Copyright (c) 2006-2007 Matias Capeletto
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 /// \file container_adaptor/vector_adaptor.hpp
10 /// \brief Container adaptor to easily build a std::vector signature compatible container.
12 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_ADAPTOR_HPP
13 #define BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_ADAPTOR_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
19 #include <boost/config.hpp>
21 #include <boost/bimap/container_adaptor/sequence_container_adaptor.hpp>
22 #include <boost/mpl/aux_/na.hpp>
23 #include <boost/mpl/vector.hpp>
27 namespace container_adaptor
{
29 /// \brief Container adaptor to easily build a std::vector signature compatible container.
37 class ReverseIterator
,
38 class ConstReverseIterator
,
40 class IteratorToBaseConverter
= ::boost::mpl::na
,
41 class IteratorFromBaseConverter
= ::boost::mpl::na
,
42 class ReverseIteratorFromBaseConverter
= ::boost::mpl::na
,
43 class ValueToBaseConverter
= ::boost::mpl::na
,
44 class ValueFromBaseConverter
= ::boost::mpl::na
,
46 class FunctorsFromDerivedClasses
= mpl::vector
<>
48 class vector_adaptor
:
50 public ::boost::bimaps::container_adaptor::sequence_container_adaptor
53 Iterator
, ConstIterator
, ReverseIterator
, ConstReverseIterator
,
54 IteratorToBaseConverter
, IteratorFromBaseConverter
,
55 ReverseIteratorFromBaseConverter
,
56 ValueToBaseConverter
, ValueFromBaseConverter
,
57 FunctorsFromDerivedClasses
61 typedef ::boost::bimaps::container_adaptor::sequence_container_adaptor
64 Iterator
, ConstIterator
, ReverseIterator
, ConstReverseIterator
,
65 IteratorToBaseConverter
, IteratorFromBaseConverter
,
66 ReverseIteratorFromBaseConverter
,
67 ValueToBaseConverter
, ValueFromBaseConverter
,
68 FunctorsFromDerivedClasses
72 // Access -----------------------------------------------------------------
78 explicit vector_adaptor(Base
& c
) :
83 typedef vector_adaptor vector_adaptor_
;
85 // Interface --------------------------------------------------------------
89 BOOST_DEDUCED_TYPENAME
base_::size_type
capacity() const
91 return this->base().capacity();
94 void reserve(BOOST_DEDUCED_TYPENAME
base_::size_type m
)
96 this->base().resize(m
);
99 void resize(BOOST_DEDUCED_TYPENAME
base_::size_type n
,
100 BOOST_DEDUCED_TYPENAME ::boost::call_traits
<
101 BOOST_DEDUCED_TYPENAME
base_::value_type
>::param_type x
=
102 BOOST_DEDUCED_TYPENAME
base_::value_type())
104 this->base().resize(n
,
105 this->template functor
<BOOST_DEDUCED_TYPENAME
base_::value_to_base
>()(x
)
109 BOOST_DEDUCED_TYPENAME
base_::const_reference
110 operator[](BOOST_DEDUCED_TYPENAME
base_::size_type n
) const
112 return this->base().operator[](n
);
115 BOOST_DEDUCED_TYPENAME
base_::const_reference
116 at(BOOST_DEDUCED_TYPENAME
base_::size_type n
) const
118 return this->base().at(n
);
121 BOOST_DEDUCED_TYPENAME
base_::reference
122 operator[](BOOST_DEDUCED_TYPENAME
base_::size_type n
)
124 return this->base().operator[](n
);
127 BOOST_DEDUCED_TYPENAME
base_::reference
128 at(BOOST_DEDUCED_TYPENAME
base_::size_type n
)
130 return this->base().at(n
);
135 } // namespace container_adaptor
136 } // namespace bimaps
140 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_ADAPTOR_HPP