annotate DEPENDENCIES/generic/include/boost/assign/ptr_list_of.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Assign library
Chris@16 2 //
Chris@16 3 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
Chris@16 4 // distribution is subject to the Boost Software License, Version
Chris@16 5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 //
Chris@16 8 // For more information, see http://www.boost.org/libs/assign/
Chris@16 9 //
Chris@16 10
Chris@16 11
Chris@16 12 #ifndef BOOST_ASSIGN_PTR_LIST_OF_HPP
Chris@16 13 #define BOOST_ASSIGN_PTR_LIST_OF_HPP
Chris@16 14
Chris@101 15 #if defined(_MSC_VER)
Chris@16 16 # pragma once
Chris@16 17 #endif
Chris@16 18
Chris@16 19 #include <boost/assign/list_of.hpp>
Chris@16 20 #include <boost/type_traits/remove_const.hpp>
Chris@16 21 #include <boost/type_traits/remove_reference.hpp>
Chris@16 22 #include <boost/type_traits/is_reference.hpp>
Chris@16 23 #include <boost/static_assert.hpp>
Chris@16 24 #include <boost/type_traits/detail/yes_no_type.hpp>
Chris@16 25 #include <boost/type_traits/decay.hpp>
Chris@16 26 #include <boost/type_traits/is_array.hpp>
Chris@16 27 #include <boost/mpl/if.hpp>
Chris@16 28 #include <boost/ptr_container/ptr_vector.hpp>
Chris@16 29
Chris@16 30 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
Chris@16 31 #include <boost/preprocessor/repetition/enum_params.hpp>
Chris@16 32 #include <boost/preprocessor/iteration/local.hpp>
Chris@16 33
Chris@16 34 namespace boost
Chris@16 35 {
Chris@16 36
Chris@16 37 namespace assign_detail
Chris@16 38 {
Chris@16 39 /////////////////////////////////////////////////////////////////////////
Chris@16 40 // Part 1: flexible and efficient interface
Chris@16 41 /////////////////////////////////////////////////////////////////////////
Chris@16 42
Chris@16 43 template< class T >
Chris@16 44 class generic_ptr_list :
Chris@16 45 public converter< generic_ptr_list<T>,
Chris@16 46 BOOST_DEDUCED_TYPENAME boost::ptr_vector<T>::iterator >
Chris@16 47 {
Chris@16 48 protected:
Chris@16 49 typedef boost::ptr_vector<T> impl_type;
Chris@16 50 typedef std::auto_ptr<impl_type> release_type;
Chris@16 51 mutable impl_type values_;
Chris@16 52
Chris@16 53 public:
Chris@16 54 typedef BOOST_DEDUCED_TYPENAME impl_type::iterator iterator;
Chris@16 55 typedef iterator const_iterator;
Chris@16 56 typedef BOOST_DEDUCED_TYPENAME impl_type::value_type value_type;
Chris@16 57 typedef BOOST_DEDUCED_TYPENAME impl_type::size_type size_type;
Chris@16 58 typedef BOOST_DEDUCED_TYPENAME impl_type::difference_type difference_type;
Chris@16 59 public:
Chris@16 60 generic_ptr_list() : values_( 32u )
Chris@16 61 { }
Chris@16 62
Chris@16 63 generic_ptr_list( release_type r ) : values_(r)
Chris@16 64 { }
Chris@16 65
Chris@16 66 release_type release()
Chris@16 67 {
Chris@16 68 return values_.release();
Chris@16 69 }
Chris@16 70
Chris@16 71 public:
Chris@16 72 iterator begin() const { return values_.begin(); }
Chris@16 73 iterator end() const { return values_.end(); }
Chris@16 74 bool empty() const { return values_.empty(); }
Chris@16 75 size_type size() const { return values_.size(); }
Chris@16 76
Chris@16 77 public:
Chris@16 78
Chris@16 79 operator impl_type() const
Chris@16 80 {
Chris@16 81 return values_;
Chris@16 82 }
Chris@16 83
Chris@16 84 template< template<class,class,class> class Seq, class U,
Chris@16 85 class CA, class A >
Chris@16 86 operator Seq<U,CA,A>() const
Chris@16 87 {
Chris@16 88 Seq<U,CA,A> result;
Chris@16 89 result.transfer( result.end(), values_ );
Chris@16 90 BOOST_ASSERT( empty() );
Chris@16 91 return result;
Chris@16 92 }
Chris@16 93
Chris@16 94 template< class PtrContainer >
Chris@16 95 std::auto_ptr<PtrContainer> convert( const PtrContainer* c ) const
Chris@16 96 {
Chris@16 97 std::auto_ptr<PtrContainer> res( new PtrContainer() );
Chris@16 98 while( !empty() )
Chris@16 99 res->insert( res->end(),
Chris@16 100 values_.pop_back().release() );
Chris@16 101 return res;
Chris@16 102 }
Chris@16 103
Chris@16 104 template< class PtrContainer >
Chris@16 105 std::auto_ptr<PtrContainer> to_container( const PtrContainer& c ) const
Chris@16 106 {
Chris@16 107 return convert( &c );
Chris@16 108 }
Chris@16 109
Chris@16 110 protected:
Chris@16 111 void push_back( T* r ) { values_.push_back( r ); }
Chris@16 112
Chris@16 113 public:
Chris@16 114 generic_ptr_list& operator()()
Chris@16 115 {
Chris@16 116 this->push_back( new T() );
Chris@16 117 return *this;
Chris@16 118 }
Chris@16 119
Chris@16 120 template< class U >
Chris@16 121 generic_ptr_list& operator()( const U& u )
Chris@16 122 {
Chris@16 123 this->push_back( new T(u) );
Chris@16 124 return *this;
Chris@16 125 }
Chris@16 126
Chris@16 127
Chris@16 128 #ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
Chris@16 129 #define BOOST_ASSIGN_MAX_PARAMS 5
Chris@16 130 #endif
Chris@16 131 #define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
Chris@16 132 #define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class U)
Chris@16 133 #define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, const& u)
Chris@16 134 #define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, u)
Chris@16 135
Chris@16 136 #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
Chris@16 137 #define BOOST_PP_LOCAL_MACRO(n) \
Chris@16 138 template< class U, BOOST_ASSIGN_PARAMS1(n) > \
Chris@16 139 generic_ptr_list& operator()(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
Chris@16 140 { \
Chris@16 141 this->push_back( new T(u, BOOST_ASSIGN_PARAMS3(n))); \
Chris@16 142 return *this; \
Chris@16 143 } \
Chris@16 144 /**/
Chris@16 145
Chris@16 146 #include BOOST_PP_LOCAL_ITERATE()
Chris@16 147
Chris@16 148 }; // class 'generic_ptr_list'
Chris@16 149
Chris@16 150 } // namespace 'assign_detail'
Chris@16 151
Chris@16 152 namespace assign
Chris@16 153 {
Chris@16 154 template< class T >
Chris@16 155 inline assign_detail::generic_ptr_list<T>
Chris@16 156 ptr_list_of()
Chris@16 157 {
Chris@16 158 return assign_detail::generic_ptr_list<T>()();
Chris@16 159 }
Chris@16 160
Chris@16 161 template< class T, class U >
Chris@16 162 inline assign_detail::generic_ptr_list<T>
Chris@16 163 ptr_list_of( const U& t )
Chris@16 164 {
Chris@16 165 return assign_detail::generic_ptr_list<T>()( t );
Chris@16 166 }
Chris@16 167
Chris@16 168
Chris@16 169 #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
Chris@16 170 #define BOOST_PP_LOCAL_MACRO(n) \
Chris@16 171 template< class T, class U, BOOST_ASSIGN_PARAMS1(n) > \
Chris@16 172 inline assign_detail::generic_ptr_list<T> \
Chris@16 173 ptr_list_of(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
Chris@16 174 { \
Chris@16 175 return assign_detail::generic_ptr_list<T>()(u, BOOST_ASSIGN_PARAMS3(n)); \
Chris@16 176 } \
Chris@16 177 /**/
Chris@16 178
Chris@16 179 #include BOOST_PP_LOCAL_ITERATE()
Chris@16 180
Chris@16 181
Chris@16 182 } // namespace 'assign'
Chris@16 183 } // namespace 'boost'
Chris@16 184
Chris@16 185
Chris@16 186 #undef BOOST_ASSIGN_PARAMS1
Chris@16 187 #undef BOOST_ASSIGN_PARAMS2
Chris@16 188 #undef BOOST_ASSIGN_PARAMS3
Chris@16 189 #undef BOOST_ASSIGN_MAX_PARAMETERS
Chris@16 190
Chris@16 191 #endif