list_of.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. // Boost.Assign library
  2. //
  3. // Copyright Thorsten Ottosen 2003-2004. Use, modification and
  4. // distribution is subject to the Boost Software License, Version
  5. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // For more information, see http://www.boost.org/libs/assign/
  9. //
  10. #ifndef BOOST_ASSIGN_LIST_OF_HPP
  11. #define BOOST_ASSIGN_LIST_OF_HPP
  12. #if defined(_MSC_VER)
  13. # pragma once
  14. #endif
  15. #include <boost/assign/assignment_exception.hpp>
  16. #include <boost/range/iterator_range.hpp>
  17. #include <boost/config.hpp>
  18. #include <boost/tuple/tuple.hpp>
  19. #include <boost/type_traits/remove_const.hpp>
  20. #include <boost/type_traits/remove_reference.hpp>
  21. #include <boost/type_traits/is_reference.hpp>
  22. #include <boost/static_assert.hpp>
  23. #include <boost/throw_exception.hpp>
  24. #include <boost/type_traits/detail/yes_no_type.hpp>
  25. #include <boost/type_traits/decay.hpp>
  26. #include <boost/type_traits/is_array.hpp>
  27. #include <boost/utility/enable_if.hpp>
  28. #include <boost/utility/declval.hpp>
  29. #include <boost/mpl/if.hpp>
  30. #include <boost/move/utility.hpp>
  31. #include <deque>
  32. #include <cstddef>
  33. #include <utility>
  34. #ifndef BOOST_NO_CXX11_HDR_ARRAY
  35. #include <array>
  36. #endif
  37. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  38. #include <initializer_list>
  39. #endif
  40. // some gcc < 4.7 do not support all of the variadic features required for boost::assign
  41. #if !(defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || BOOST_WORKAROUND(BOOST_GCC, < 40700) \
  42. || defined(BOOST_NO_CXX11_RVALUE_REFERENCES))
  43. # define BOOST_ASSIGN_USE_VARIADIC_TEMPLATES
  44. #endif
  45. #if !defined(BOOST_ASSIGN_USE_VARIADIC_TEMPLATES)
  46. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  47. #include <boost/preprocessor/repetition/enum_params.hpp>
  48. #include <boost/preprocessor/iteration/local.hpp>
  49. #endif
  50. #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
  51. // BCB requires full type definition for is_array<> to work correctly.
  52. #include <boost/array.hpp>
  53. #endif
  54. namespace boost
  55. {
  56. // this here is necessary to avoid compiler error in <boost/array.hpp>
  57. #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
  58. template< class T, std::size_t sz >
  59. class array;
  60. #endif
  61. namespace assign_detail
  62. {
  63. /////////////////////////////////////////////////////////////////////////
  64. // Part 0: common conversion code
  65. /////////////////////////////////////////////////////////////////////////
  66. template< class T >
  67. struct assign_decay
  68. {
  69. //
  70. // Add constness to array parameters
  71. // to support string literals properly
  72. //
  73. typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
  74. ::boost::is_array<T>,
  75. ::boost::decay<const T>,
  76. ::boost::decay<T> >::type type;
  77. };
  78. template< class T, std::size_t sz >
  79. type_traits::yes_type assign_is_array( const array<T,sz>* );
  80. #ifndef BOOST_NO_CXX11_HDR_ARRAY
  81. template< class T, std::size_t sz >
  82. type_traits::yes_type assign_is_array( const std::array<T, sz>* );
  83. #endif
  84. type_traits::no_type assign_is_array( ... );
  85. template< class T, class U >
  86. type_traits::yes_type assign_is_pair( const std::pair<T,U>* );
  87. type_traits::no_type assign_is_pair( ... );
  88. struct array_type_tag
  89. {
  90. #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
  91. private:
  92. char dummy_; // BCB would by default use 8 bytes
  93. #endif
  94. };
  95. struct adapter_type_tag
  96. {
  97. #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
  98. private:
  99. char dummy_; // BCB would by default use 8 bytes
  100. #endif
  101. };
  102. struct pair_type_tag
  103. {
  104. #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
  105. private:
  106. char dummy_; // BCB would by default use 8 bytes
  107. #endif
  108. };
  109. struct default_type_tag
  110. {
  111. #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
  112. private:
  113. char dummy_; // BCB would by default use 8 bytes
  114. #endif
  115. };
  116. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  117. template< class C >
  118. struct is_initializer_list : boost::false_type {};
  119. template< class E >
  120. struct is_initializer_list< std::initializer_list<E> > : boost::true_type {};
  121. #endif
  122. template< class DerivedTAssign, class Iterator >
  123. class converter
  124. {
  125. public: // Range operations
  126. typedef Iterator iterator;
  127. typedef Iterator const_iterator;
  128. iterator begin() const
  129. {
  130. return static_cast<const DerivedTAssign*>(this)->begin();
  131. }
  132. iterator end() const
  133. {
  134. return static_cast<const DerivedTAssign*>(this)->end();
  135. }
  136. public:
  137. template< class Container >
  138. Container convert_to_container() const
  139. {
  140. static Container* c = 0;
  141. BOOST_STATIC_CONSTANT( bool, is_array_flag = sizeof( assign_detail::assign_is_array( c ) )
  142. == sizeof( type_traits::yes_type ) );
  143. typedef BOOST_DEDUCED_TYPENAME mpl::if_c< is_array_flag,
  144. array_type_tag,
  145. default_type_tag >::type tag_type;
  146. return convert<Container>( c, tag_type() );
  147. }
  148. private:
  149. template< class Container >
  150. Container convert( const Container*, default_type_tag ) const
  151. {
  152. #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
  153. // old Dinkumware doesn't support iterator type as template
  154. Container result;
  155. iterator it = begin(),
  156. e = end();
  157. while( it != e )
  158. {
  159. result.insert( result.end(), *it );
  160. ++it;
  161. }
  162. return result;
  163. #else
  164. return Container( begin(), end() );
  165. #endif
  166. }
  167. template< class Array >
  168. Array convert( const Array*, array_type_tag ) const
  169. {
  170. typedef BOOST_DEDUCED_TYPENAME Array::value_type value_type;
  171. #if BOOST_WORKAROUND(BOOST_INTEL, <= 910 ) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5100 )
  172. BOOST_DEDUCED_TYPENAME remove_const<Array>::type ar;
  173. #else
  174. Array ar;
  175. #endif
  176. const std::size_t sz = ar.size();
  177. if( sz < static_cast<const DerivedTAssign*>(this)->size() )
  178. BOOST_THROW_EXCEPTION( assign::assignment_exception( "array initialized with too many elements" ) );
  179. std::size_t n = 0;
  180. iterator i = begin(),
  181. e = end();
  182. for( ; i != e; ++i, ++n )
  183. ar[n] = *i;
  184. for( ; n < sz; ++n )
  185. ar[n] = value_type();
  186. return ar;
  187. }
  188. template< class Adapter >
  189. Adapter convert_to_adapter( const Adapter* = 0 ) const
  190. {
  191. Adapter a;
  192. iterator i = begin(),
  193. e = end();
  194. for( ; i != e; ++i )
  195. a.push( *i );
  196. return a;
  197. }
  198. private:
  199. struct adapter_converter;
  200. friend struct adapter_converter;
  201. struct adapter_converter
  202. {
  203. const converter& gl;
  204. adapter_converter( const converter& this_ ) : gl( this_ )
  205. {}
  206. adapter_converter( const adapter_converter& r )
  207. : gl( r.gl )
  208. { }
  209. template< class Adapter >
  210. operator Adapter() const
  211. {
  212. return gl.convert_to_adapter<Adapter>();
  213. }
  214. };
  215. public:
  216. template< class Container >
  217. Container to_container( Container& c ) const
  218. {
  219. return convert( &c, default_type_tag() );
  220. }
  221. adapter_converter to_adapter() const
  222. {
  223. return adapter_converter( *this );
  224. }
  225. template< class Adapter >
  226. Adapter to_adapter( Adapter& a ) const
  227. {
  228. return this->convert_to_adapter( &a );
  229. }
  230. template< class Array >
  231. Array to_array( Array& a ) const
  232. {
  233. return convert( &a, array_type_tag() );
  234. }
  235. };
  236. template< class T, class I, class Range >
  237. inline bool operator==( const converter<T,I>& l, const Range& r )
  238. {
  239. return ::boost::iterator_range_detail::equal( l, r );
  240. }
  241. template< class T, class I, class Range >
  242. inline bool operator==( const Range& l, const converter<T,I>& r )
  243. {
  244. return r == l;
  245. }
  246. template< class T, class I, class Range >
  247. inline bool operator!=( const converter<T,I>& l, const Range& r )
  248. {
  249. return !( l == r );
  250. }
  251. template< class T, class I, class Range >
  252. inline bool operator!=( const Range& l, const converter<T,I>& r )
  253. {
  254. return !( l == r );
  255. }
  256. template< class T, class I, class Range >
  257. inline bool operator<( const converter<T,I>& l, const Range& r )
  258. {
  259. return ::boost::iterator_range_detail::less_than( l, r );
  260. }
  261. template< class T, class I, class Range >
  262. inline bool operator<( const Range& l, const converter<T,I>& r )
  263. {
  264. return ::boost::iterator_range_detail::less_than( l, r );
  265. }
  266. template< class T, class I, class Range >
  267. inline bool operator>( const converter<T,I>& l, const Range& r )
  268. {
  269. return r < l;
  270. }
  271. template< class T, class I, class Range >
  272. inline bool operator>( const Range& l, const converter<T,I>& r )
  273. {
  274. return r < l;
  275. }
  276. template< class T, class I, class Range >
  277. inline bool operator<=( const converter<T,I>& l, const Range& r )
  278. {
  279. return !( l > r );
  280. }
  281. template< class T, class I, class Range >
  282. inline bool operator<=( const Range& l, const converter<T,I>& r )
  283. {
  284. return !( l > r );
  285. }
  286. template< class T, class I, class Range >
  287. inline bool operator>=( const converter<T,I>& l, const Range& r )
  288. {
  289. return !( l < r );
  290. }
  291. template< class T, class I, class Range >
  292. inline bool operator>=( const Range& l, const converter<T,I>& r )
  293. {
  294. return !( l < r );
  295. }
  296. template< class T, class I, class Elem, class Traits >
  297. inline std::basic_ostream<Elem,Traits>&
  298. operator<<( std::basic_ostream<Elem, Traits>& Os,
  299. const converter<T,I>& r )
  300. {
  301. return Os << ::boost::make_iterator_range( r.begin(), r.end() );
  302. }
  303. /////////////////////////////////////////////////////////////////////////
  304. // Part 1: flexible, but inefficient interface
  305. /////////////////////////////////////////////////////////////////////////
  306. template< class T >
  307. class generic_list :
  308. public converter< generic_list< BOOST_DEDUCED_TYPENAME assign_decay<T>::type >,
  309. BOOST_DEDUCED_TYPENAME std::deque<BOOST_DEDUCED_TYPENAME
  310. assign_decay<T>::type>::iterator >
  311. {
  312. typedef BOOST_DEDUCED_TYPENAME assign_decay<T>::type Ty;
  313. typedef std::deque<Ty> impl_type;
  314. mutable impl_type values_;
  315. public:
  316. typedef BOOST_DEDUCED_TYPENAME impl_type::iterator iterator;
  317. typedef iterator const_iterator;
  318. typedef BOOST_DEDUCED_TYPENAME impl_type::value_type value_type;
  319. typedef BOOST_DEDUCED_TYPENAME impl_type::size_type size_type;
  320. typedef BOOST_DEDUCED_TYPENAME impl_type::difference_type difference_type;
  321. public:
  322. iterator begin() const { return values_.begin(); }
  323. iterator end() const { return values_.end(); }
  324. bool empty() const { return values_.empty(); }
  325. size_type size() const { return values_.size(); }
  326. private:
  327. #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  328. void push_back( value_type r ) { values_.push_back( r ); }
  329. #else
  330. void push_back( const value_type& r ) { values_.push_back( r ); }
  331. void push_back( value_type&& r ) { values_.push_back( boost::move( r ) ); }
  332. #endif
  333. public:
  334. generic_list& operator,( const Ty& u )
  335. {
  336. this->push_back( u );
  337. return *this;
  338. }
  339. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  340. generic_list& operator,( Ty&& u )
  341. {
  342. this->push_back( boost::move(u) );
  343. return *this;
  344. }
  345. #endif
  346. generic_list& operator()( const Ty& u )
  347. {
  348. this->push_back( u );
  349. return *this;
  350. }
  351. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  352. generic_list& operator()(Ty&& u)
  353. {
  354. this->push_back( boost::move(u) );
  355. return *this;
  356. }
  357. #endif
  358. generic_list& operator()()
  359. {
  360. this->push_back( Ty() );
  361. return *this;
  362. }
  363. #if !defined(BOOST_ASSIGN_USE_VARIADIC_TEMPLATES)
  364. #ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
  365. #define BOOST_ASSIGN_MAX_PARAMS 5
  366. #endif
  367. #define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
  368. #define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class U)
  369. #define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, const& u)
  370. #define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, u)
  371. #define BOOST_ASSIGN_PARAMS4(n) BOOST_PP_ENUM_PARAMS(n, U)
  372. #define BOOST_ASSIGN_PARAMS2_NO_REF(n) BOOST_PP_ENUM_BINARY_PARAMS(n, U, u)
  373. #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
  374. #define BOOST_PP_LOCAL_MACRO(n) \
  375. template< class U, BOOST_ASSIGN_PARAMS1(n) > \
  376. generic_list& operator()(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
  377. { \
  378. this->push_back( Ty(u, BOOST_ASSIGN_PARAMS3(n))); \
  379. return *this; \
  380. } \
  381. /**/
  382. #include BOOST_PP_LOCAL_ITERATE()
  383. #else
  384. template< class U0, class U1, class... Us >
  385. generic_list& operator()(U0&& u0, U1&& u1, Us&&... us)
  386. {
  387. this->push_back(Ty(boost::forward<U0>(u0), boost::forward<U1>(u1), boost::forward<Us>(us)...));
  388. return *this;
  389. }
  390. #endif
  391. template< class U >
  392. generic_list& repeat( std::size_t sz, U u )
  393. {
  394. std::size_t i = 0;
  395. while( i++ != sz )
  396. this->push_back( u );
  397. return *this;
  398. }
  399. template< class Nullary_function >
  400. generic_list& repeat_fun( std::size_t sz, Nullary_function fun )
  401. {
  402. std::size_t i = 0;
  403. while( i++ != sz )
  404. this->push_back( fun() );
  405. return *this;
  406. }
  407. template< class SinglePassIterator >
  408. generic_list& range( SinglePassIterator first,
  409. SinglePassIterator last )
  410. {
  411. for( ; first != last; ++first )
  412. this->push_back( *first );
  413. return *this;
  414. }
  415. template< class SinglePassRange >
  416. generic_list& range( const SinglePassRange& r )
  417. {
  418. return range( boost::begin(r), boost::end(r) );
  419. }
  420. #if !defined(BOOST_NO_CXX11_DECLTYPE_N3276) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  421. template< class Container,
  422. class = decltype(Container(
  423. boost::declval<BOOST_DEDUCED_TYPENAME std::deque<BOOST_DEDUCED_TYPENAME assign_decay<T>::type>::iterator>(),
  424. boost::declval<BOOST_DEDUCED_TYPENAME std::deque<BOOST_DEDUCED_TYPENAME assign_decay<T>::type>::iterator>()
  425. ))
  426. >
  427. operator Container() const
  428. {
  429. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  430. }
  431. template< class Container,
  432. class = typename boost::enable_if< boost::is_same< boost::type_traits::yes_type, decltype(assign_is_array((Container*)0))> >::type,
  433. class = void
  434. >
  435. operator Container() const
  436. {
  437. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  438. }
  439. #elif !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  440. template< class Container
  441. # if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  442. , class = typename boost::disable_if< is_initializer_list<Container> >::type
  443. # endif
  444. , class = typename Container::iterator
  445. >
  446. operator Container() const
  447. {
  448. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  449. }
  450. #else
  451. template< class Container >
  452. operator Container() const
  453. {
  454. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  455. }
  456. #endif
  457. };
  458. /////////////////////////////////////////////////////////////////////////
  459. // Part 2: efficient, but inconvenient interface
  460. /////////////////////////////////////////////////////////////////////////
  461. template< class T >
  462. struct assign_reference
  463. {
  464. assign_reference() : ref_(0)
  465. { /* intentionally empty */ }
  466. assign_reference( T& r ) : ref_(&r)
  467. { }
  468. void operator=( T& r )
  469. {
  470. ref_ = &r;
  471. }
  472. operator T&() const
  473. {
  474. return *ref_;
  475. }
  476. void swap( assign_reference& r )
  477. {
  478. std::swap( *ref_, *r.ref_ );
  479. }
  480. T& get_ref() const
  481. {
  482. return *ref_;
  483. }
  484. private:
  485. T* ref_;
  486. };
  487. template< class T >
  488. inline bool operator<( const assign_reference<T>& l,
  489. const assign_reference<T>& r )
  490. {
  491. return l.get_ref() < r.get_ref();
  492. }
  493. template< class T >
  494. inline bool operator>( const assign_reference<T>& l,
  495. const assign_reference<T>& r )
  496. {
  497. return l.get_ref() > r.get_ref();
  498. }
  499. template< class T >
  500. inline void swap( assign_reference<T>& l,
  501. assign_reference<T>& r )
  502. {
  503. l.swap( r );
  504. }
  505. template< class T, int N >
  506. struct static_generic_list :
  507. public converter< static_generic_list<T,N>, assign_reference<T>* >
  508. {
  509. private:
  510. typedef T internal_value_type;
  511. public:
  512. typedef assign_reference<internal_value_type> value_type;
  513. typedef value_type* iterator;
  514. typedef value_type* const_iterator;
  515. typedef std::size_t size_type;
  516. typedef std::ptrdiff_t difference_type;
  517. static_generic_list( T& r ) :
  518. current_(1)
  519. {
  520. refs_[0] = r;
  521. }
  522. static_generic_list& operator()( T& r )
  523. {
  524. insert( r );
  525. return *this;
  526. }
  527. iterator begin() const
  528. {
  529. return &refs_[0];
  530. }
  531. iterator end() const
  532. {
  533. return &refs_[current_];
  534. }
  535. size_type size() const
  536. {
  537. return static_cast<size_type>( current_ );
  538. }
  539. bool empty() const
  540. {
  541. return false;
  542. }
  543. template< class ForwardIterator >
  544. static_generic_list& range( ForwardIterator first,
  545. ForwardIterator last )
  546. {
  547. for( ; first != last; ++first )
  548. this->insert( *first );
  549. return *this;
  550. }
  551. template< class ForwardRange >
  552. static_generic_list& range( ForwardRange& r )
  553. {
  554. return range( boost::begin(r), boost::end(r) );
  555. }
  556. template< class ForwardRange >
  557. static_generic_list& range( const ForwardRange& r )
  558. {
  559. return range( boost::begin(r), boost::end(r) );
  560. }
  561. #if !defined(BOOST_NO_CXX11_DECLTYPE_N3276) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  562. template< class Container,
  563. class = decltype(Container(boost::declval<assign_reference<T>*>(), boost::declval<assign_reference<T>*>()))
  564. >
  565. operator Container() const
  566. {
  567. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  568. }
  569. template< class Container,
  570. class = typename boost::enable_if< boost::is_same< boost::type_traits::yes_type, decltype(assign_is_array((Container*)0))> >::type,
  571. class = void
  572. >
  573. operator Container() const
  574. {
  575. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  576. }
  577. #elif !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  578. template< class Container
  579. # if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  580. , class = typename boost::disable_if< is_initializer_list<Container> >::type
  581. # endif
  582. , class = typename Container::iterator
  583. >
  584. operator Container() const
  585. {
  586. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  587. }
  588. #else
  589. template< class Container >
  590. operator Container() const
  591. {
  592. return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
  593. }
  594. #endif
  595. private:
  596. void insert( T& r )
  597. {
  598. refs_[current_] = r;
  599. ++current_;
  600. }
  601. static_generic_list();
  602. mutable assign_reference<internal_value_type> refs_[N];
  603. int current_;
  604. };
  605. } // namespace 'assign_detail'
  606. namespace assign
  607. {
  608. template< class T >
  609. inline assign_detail::generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type>
  610. list_of()
  611. {
  612. assign_detail::generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type> gl;
  613. gl();
  614. return gl;
  615. }
  616. #if !defined(BOOST_ASSIGN_USE_VARIADIC_TEMPLATES)
  617. template< class T >
  618. inline assign_detail::generic_list<T>
  619. list_of( const T& t )
  620. {
  621. return assign_detail::generic_list<T>()( t );
  622. }
  623. #else
  624. template< class T >
  625. inline assign_detail::generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type>
  626. list_of(T&& t)
  627. {
  628. assign_detail::generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type> gl;
  629. gl(boost::forward<T>(t));
  630. return gl;
  631. }
  632. #endif
  633. template< int N, class T >
  634. inline assign_detail::static_generic_list< BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>
  635. ref_list_of( T& t )
  636. {
  637. return assign_detail::static_generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>( t );
  638. }
  639. template< int N, class T >
  640. inline assign_detail::static_generic_list<const BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>
  641. cref_list_of( const T& t )
  642. {
  643. return assign_detail::static_generic_list<const BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type,N>( t );
  644. }
  645. #if !defined(BOOST_ASSIGN_USE_VARIADIC_TEMPLATES)
  646. #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
  647. #define BOOST_PP_LOCAL_MACRO(n) \
  648. template< class T, class U, BOOST_ASSIGN_PARAMS1(n) > \
  649. inline assign_detail::generic_list<T> \
  650. list_of(U const& u, BOOST_ASSIGN_PARAMS2(n) ) \
  651. { \
  652. return assign_detail::generic_list<T>()(u, BOOST_ASSIGN_PARAMS3(n)); \
  653. } \
  654. /**/
  655. #include BOOST_PP_LOCAL_ITERATE()
  656. #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
  657. #define BOOST_PP_LOCAL_MACRO(n) \
  658. template< class U, BOOST_ASSIGN_PARAMS1(n) > \
  659. inline assign_detail::generic_list< tuple<U, BOOST_ASSIGN_PARAMS4(n)> > \
  660. tuple_list_of(U u, BOOST_ASSIGN_PARAMS2_NO_REF(n) ) \
  661. { \
  662. return assign_detail::generic_list< tuple<U, BOOST_ASSIGN_PARAMS4(n)> >()( tuple<U,BOOST_ASSIGN_PARAMS4(n)>( u, BOOST_ASSIGN_PARAMS3(n) )); \
  663. } \
  664. /**/
  665. #include BOOST_PP_LOCAL_ITERATE()
  666. #else
  667. template< class T, class U, class... Us >
  668. inline assign_detail::generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type>
  669. list_of(U&& u, Us&&... us)
  670. {
  671. assign_detail::generic_list<BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type> gl;
  672. gl(boost::forward<U>(u), boost::forward<Us>(us)...);
  673. return gl;
  674. }
  675. template< class U, class... Us >
  676. inline assign_detail::generic_list< tuple<U, Us...> >
  677. tuple_list_of(U u, Us... us)
  678. {
  679. assign_detail::generic_list< tuple<U, Us...> > gl;
  680. gl(tuple<U, Us...>(u, us...));
  681. return gl;
  682. }
  683. #endif
  684. template< class Key, class T >
  685. inline assign_detail::generic_list< std::pair
  686. <
  687. BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<Key>::type,
  688. BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type
  689. > >
  690. map_list_of( const Key& k, const T& t )
  691. {
  692. typedef BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<Key>::type k_type;
  693. typedef BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<T>::type t_type;
  694. return assign_detail::generic_list< std::pair<k_type,t_type> >()( k, t );
  695. }
  696. template< class F, class S >
  697. inline assign_detail::generic_list< std::pair
  698. <
  699. BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<F>::type,
  700. BOOST_DEDUCED_TYPENAME assign_detail::assign_decay<S>::type
  701. > >
  702. pair_list_of( const F& f, const S& s )
  703. {
  704. return map_list_of( f, s );
  705. }
  706. } // namespace 'assign'
  707. } // namespace 'boost'
  708. #if !defined(BOOST_ASSIGN_USE_VARIADIC_TEMPLATES)
  709. #undef BOOST_ASSIGN_PARAMS1
  710. #undef BOOST_ASSIGN_PARAMS2
  711. #undef BOOST_ASSIGN_PARAMS3
  712. #undef BOOST_ASSIGN_PARAMS4
  713. #undef BOOST_ASSIGN_PARAMS2_NO_REF
  714. #undef BOOST_ASSIGN_MAX_PARAMETERS
  715. #endif
  716. #endif