ptr_set_adapter.hpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. //
  2. // Boost.Pointer Container
  3. //
  4. // Copyright Thorsten Ottosen 2003-2005. Use, modification and
  5. // distribution is subject to the Boost Software License, Version
  6. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // For more information, see http://www.boost.org/libs/ptr_container/
  10. //
  11. #ifndef BOOST_PTR_CONTAINER_PTR_SET_ADAPTER_HPP
  12. #define BOOST_PTR_CONTAINER_PTR_SET_ADAPTER_HPP
  13. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  14. # pragma once
  15. #endif
  16. #include <boost/ptr_container/detail/associative_ptr_container.hpp>
  17. #include <boost/ptr_container/detail/meta_functions.hpp>
  18. #include <boost/ptr_container/detail/void_ptr_iterator.hpp>
  19. #include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
  20. #include <boost/range/iterator_range.hpp>
  21. #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
  22. #pragma GCC diagnostic push
  23. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  24. #endif
  25. namespace boost
  26. {
  27. namespace ptr_container_detail
  28. {
  29. template
  30. <
  31. class Key,
  32. class VoidPtrSet,
  33. bool Ordered
  34. >
  35. struct set_config
  36. {
  37. typedef VoidPtrSet
  38. void_container_type;
  39. typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
  40. allocator_type;
  41. typedef Key value_type;
  42. typedef value_type
  43. key_type;
  44. typedef BOOST_DEDUCED_TYPENAME
  45. mpl::eval_if_c<Ordered,
  46. select_value_compare<VoidPtrSet>,
  47. mpl::identity<void> >::type
  48. value_compare;
  49. typedef value_compare
  50. key_compare;
  51. typedef BOOST_DEDUCED_TYPENAME
  52. mpl::eval_if_c<Ordered,
  53. mpl::identity<void>,
  54. select_hasher<VoidPtrSet> >::type
  55. hasher;
  56. typedef BOOST_DEDUCED_TYPENAME
  57. mpl::eval_if_c<Ordered,
  58. mpl::identity<void>,
  59. select_key_equal<VoidPtrSet> >::type
  60. key_equal;
  61. typedef BOOST_DEDUCED_TYPENAME
  62. mpl::if_c<Ordered,
  63. ordered_associative_container_tag,
  64. unordered_associative_container_tag>::type
  65. container_type;
  66. typedef void_ptr_iterator<
  67. BOOST_DEDUCED_TYPENAME VoidPtrSet::iterator, Key >
  68. iterator;
  69. typedef void_ptr_iterator<
  70. BOOST_DEDUCED_TYPENAME VoidPtrSet::const_iterator, const Key >
  71. const_iterator;
  72. typedef void_ptr_iterator<
  73. BOOST_DEDUCED_TYPENAME
  74. mpl::eval_if_c<Ordered,
  75. select_iterator<VoidPtrSet>,
  76. select_local_iterator<VoidPtrSet> >::type,
  77. Key >
  78. local_iterator;
  79. typedef void_ptr_iterator<
  80. BOOST_DEDUCED_TYPENAME
  81. mpl::eval_if_c<Ordered,
  82. select_iterator<VoidPtrSet>,
  83. select_const_local_iterator<VoidPtrSet> >::type,
  84. const Key >
  85. const_local_iterator;
  86. template< class Iter >
  87. static Key* get_pointer( Iter i )
  88. {
  89. return static_cast<Key*>( *i.base() );
  90. }
  91. template< class Iter >
  92. static const Key* get_const_pointer( Iter i )
  93. {
  94. return static_cast<const Key*>( *i.base() );
  95. }
  96. BOOST_STATIC_CONSTANT(bool, allow_null = false );
  97. };
  98. template
  99. <
  100. class Key,
  101. class VoidPtrSet,
  102. class CloneAllocator = heap_clone_allocator,
  103. bool Ordered = true
  104. >
  105. class ptr_set_adapter_base
  106. : public ptr_container_detail::associative_ptr_container< set_config<Key,VoidPtrSet,Ordered>,
  107. CloneAllocator >
  108. {
  109. typedef ptr_container_detail::associative_ptr_container< set_config<Key,VoidPtrSet,Ordered>,
  110. CloneAllocator >
  111. base_type;
  112. public:
  113. typedef BOOST_DEDUCED_TYPENAME base_type::iterator
  114. iterator;
  115. typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
  116. const_iterator;
  117. typedef Key key_type;
  118. typedef BOOST_DEDUCED_TYPENAME base_type::size_type
  119. size_type;
  120. public:
  121. ptr_set_adapter_base()
  122. { }
  123. template< class SizeType >
  124. ptr_set_adapter_base( SizeType n,
  125. ptr_container_detail::unordered_associative_container_tag tag )
  126. : base_type( n, tag )
  127. { }
  128. template< class Compare, class Allocator >
  129. ptr_set_adapter_base( const Compare& comp,
  130. const Allocator& a )
  131. : base_type( comp, a )
  132. { }
  133. template< class Hash, class Pred, class Allocator >
  134. ptr_set_adapter_base( const Hash& hash,
  135. const Pred& pred,
  136. const Allocator& a )
  137. : base_type( hash, pred, a )
  138. { }
  139. template< class InputIterator, class Compare, class Allocator >
  140. ptr_set_adapter_base( InputIterator first, InputIterator last,
  141. const Compare& comp,
  142. const Allocator& a )
  143. : base_type( first, last, comp, a )
  144. { }
  145. template< class InputIterator, class Hash, class Pred, class Allocator >
  146. ptr_set_adapter_base( InputIterator first, InputIterator last,
  147. const Hash& hash,
  148. const Pred& pred,
  149. const Allocator& a )
  150. : base_type( first, last, hash, pred, a )
  151. { }
  152. template< class U, class Set, class CA, bool b >
  153. ptr_set_adapter_base( const ptr_set_adapter_base<U,Set,CA,b>& r )
  154. : base_type( r )
  155. { }
  156. ptr_set_adapter_base( const ptr_set_adapter_base& r )
  157. : base_type( r )
  158. { }
  159. #ifndef BOOST_NO_AUTO_PTR
  160. template< class PtrContainer >
  161. explicit ptr_set_adapter_base( std::auto_ptr<PtrContainer> clone )
  162. : base_type( clone )
  163. { }
  164. #endif
  165. #ifndef BOOST_NO_CXX11_SMART_PTR
  166. template< class PtrContainer >
  167. explicit ptr_set_adapter_base( std::unique_ptr<PtrContainer> clone )
  168. : base_type( std::move( clone ) )
  169. { }
  170. #endif
  171. ptr_set_adapter_base& operator=( ptr_set_adapter_base r )
  172. {
  173. this->swap( r );
  174. return *this;
  175. }
  176. #ifndef BOOST_NO_AUTO_PTR
  177. template< typename PtrContainer >
  178. ptr_set_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
  179. {
  180. base_type::operator=( clone );
  181. return *this;
  182. }
  183. #endif
  184. #ifndef BOOST_NO_CXX11_SMART_PTR
  185. template< typename PtrContainer >
  186. ptr_set_adapter_base& operator=( std::unique_ptr<PtrContainer> clone )
  187. {
  188. base_type::operator=( std::move( clone ) );
  189. return *this;
  190. }
  191. #endif
  192. using base_type::erase;
  193. size_type erase( const key_type& x ) // nothrow
  194. {
  195. key_type* key = const_cast<key_type*>(&x);
  196. iterator i( this->base().find( key ) );
  197. if( i == this->end() ) // nothrow
  198. return 0u; // nothrow
  199. key = static_cast<key_type*>(*i.base()); // nothrow
  200. size_type res = this->base().erase( key ); // nothrow
  201. this->remove( key ); // nothrow
  202. return res;
  203. }
  204. iterator find( const key_type& x )
  205. {
  206. return iterator( this->base().
  207. find( const_cast<key_type*>(&x) ) );
  208. }
  209. const_iterator find( const key_type& x ) const
  210. {
  211. return const_iterator( this->base().
  212. find( const_cast<key_type*>(&x) ) );
  213. }
  214. size_type count( const key_type& x ) const
  215. {
  216. return this->base().count( const_cast<key_type*>(&x) );
  217. }
  218. iterator lower_bound( const key_type& x )
  219. {
  220. return iterator( this->base().
  221. lower_bound( const_cast<key_type*>(&x) ) );
  222. }
  223. const_iterator lower_bound( const key_type& x ) const
  224. {
  225. return const_iterator( this->base().
  226. lower_bound( const_cast<key_type*>(&x) ) );
  227. }
  228. iterator upper_bound( const key_type& x )
  229. {
  230. return iterator( this->base().
  231. upper_bound( const_cast<key_type*>(&x) ) );
  232. }
  233. const_iterator upper_bound( const key_type& x ) const
  234. {
  235. return const_iterator( this->base().
  236. upper_bound( const_cast<key_type*>(&x) ) );
  237. }
  238. iterator_range<iterator> equal_range( const key_type& x )
  239. {
  240. std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,
  241. BOOST_DEDUCED_TYPENAME base_type::ptr_iterator>
  242. p = this->base().
  243. equal_range( const_cast<key_type*>(&x) );
  244. return make_iterator_range( iterator( p.first ),
  245. iterator( p.second ) );
  246. }
  247. iterator_range<const_iterator> equal_range( const key_type& x ) const
  248. {
  249. std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator,
  250. BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator>
  251. p = this->base().
  252. equal_range( const_cast<key_type*>(&x) );
  253. return make_iterator_range( const_iterator( p.first ),
  254. const_iterator( p.second ) );
  255. }
  256. protected:
  257. size_type bucket( const key_type& key ) const
  258. {
  259. return this->base().bucket( const_cast<key_type*>(&key) );
  260. }
  261. };
  262. } // ptr_container_detail
  263. /////////////////////////////////////////////////////////////////////////
  264. // ptr_set_adapter
  265. /////////////////////////////////////////////////////////////////////////
  266. template
  267. <
  268. class Key,
  269. class VoidPtrSet,
  270. class CloneAllocator = heap_clone_allocator,
  271. bool Ordered = true
  272. >
  273. class ptr_set_adapter :
  274. public ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrSet,CloneAllocator,Ordered>
  275. {
  276. typedef ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrSet,CloneAllocator,Ordered>
  277. base_type;
  278. public: // typedefs
  279. typedef BOOST_DEDUCED_TYPENAME base_type::iterator
  280. iterator;
  281. typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
  282. const_iterator;
  283. typedef BOOST_DEDUCED_TYPENAME base_type::size_type
  284. size_type;
  285. typedef Key key_type;
  286. typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
  287. auto_type;
  288. typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
  289. allocator_type;
  290. private:
  291. template< typename II >
  292. void set_basic_clone_and_insert( II first, II last ) // basic
  293. {
  294. while( first != last )
  295. {
  296. if( this->find( *first ) == this->end() )
  297. insert( this->null_policy_allocate_clone_from_iterator( first ) ); // strong, commit
  298. ++first;
  299. }
  300. }
  301. public:
  302. ptr_set_adapter()
  303. { }
  304. template< class SizeType >
  305. ptr_set_adapter( SizeType n,
  306. ptr_container_detail::unordered_associative_container_tag tag )
  307. : base_type( n, tag )
  308. { }
  309. template< class Comp >
  310. explicit ptr_set_adapter( const Comp& comp,
  311. const allocator_type& a )
  312. : base_type( comp, a )
  313. {
  314. BOOST_ASSERT( this->empty() );
  315. }
  316. template< class SizeType, class Hash, class Pred, class Allocator >
  317. ptr_set_adapter( SizeType n,
  318. const Hash& hash,
  319. const Pred& pred,
  320. const Allocator& a )
  321. : base_type( n, hash, pred, a )
  322. { }
  323. template< class Hash, class Pred, class Allocator >
  324. ptr_set_adapter( const Hash& hash,
  325. const Pred& pred,
  326. const Allocator& a )
  327. : base_type( hash, pred, a )
  328. { }
  329. template< class InputIterator >
  330. ptr_set_adapter( InputIterator first, InputIterator last )
  331. : base_type( first, last )
  332. { }
  333. template< class InputIterator, class Compare, class Allocator >
  334. ptr_set_adapter( InputIterator first, InputIterator last,
  335. const Compare& comp,
  336. const Allocator a = Allocator() )
  337. : base_type( comp, a )
  338. {
  339. BOOST_ASSERT( this->empty() );
  340. set_basic_clone_and_insert( first, last );
  341. }
  342. template< class InputIterator, class Hash, class Pred, class Allocator >
  343. ptr_set_adapter( InputIterator first, InputIterator last,
  344. const Hash& hash,
  345. const Pred& pred,
  346. const Allocator& a )
  347. : base_type( first, last, hash, pred, a )
  348. { }
  349. explicit ptr_set_adapter( const ptr_set_adapter& r )
  350. : base_type( r )
  351. { }
  352. template< class U, class Set, class CA, bool b >
  353. explicit ptr_set_adapter( const ptr_set_adapter<U,Set,CA,b>& r )
  354. : base_type( r )
  355. { }
  356. #ifndef BOOST_NO_AUTO_PTR
  357. template< class PtrContainer >
  358. explicit ptr_set_adapter( std::auto_ptr<PtrContainer> clone )
  359. : base_type( clone )
  360. { }
  361. #endif
  362. #ifndef BOOST_NO_CXX11_SMART_PTR
  363. template< class PtrContainer >
  364. explicit ptr_set_adapter( std::unique_ptr<PtrContainer> clone )
  365. : base_type( std::move( clone ) )
  366. { }
  367. #endif
  368. template< class U, class Set, class CA, bool b >
  369. ptr_set_adapter& operator=( const ptr_set_adapter<U,Set,CA,b>& r )
  370. {
  371. base_type::operator=( r );
  372. return *this;
  373. }
  374. #ifndef BOOST_NO_AUTO_PTR
  375. template< class T >
  376. void operator=( std::auto_ptr<T> r )
  377. {
  378. base_type::operator=( r );
  379. }
  380. #endif
  381. #ifndef BOOST_NO_CXX11_SMART_PTR
  382. template< class T >
  383. void operator=( std::unique_ptr<T> r )
  384. {
  385. base_type::operator=( std::move( r ) );
  386. }
  387. #endif
  388. std::pair<iterator,bool> insert( key_type* x ) // strong
  389. {
  390. this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" );
  391. auto_type ptr( x, *this );
  392. std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
  393. res = this->base().insert( x );
  394. if( res.second )
  395. ptr.release();
  396. return std::make_pair( iterator( res.first ), res.second );
  397. }
  398. #ifndef BOOST_NO_AUTO_PTR
  399. template< class U >
  400. std::pair<iterator,bool> insert( std::auto_ptr<U> x )
  401. {
  402. return insert( x.release() );
  403. }
  404. #endif
  405. #ifndef BOOST_NO_CXX11_SMART_PTR
  406. template< class U >
  407. std::pair<iterator,bool> insert( std::unique_ptr<U> x )
  408. {
  409. return insert( x.release() );
  410. }
  411. #endif
  412. iterator insert( iterator where, key_type* x ) // strong
  413. {
  414. this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" );
  415. auto_type ptr( x, *this );
  416. BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
  417. res = this->base().insert( where.base(), x );
  418. if( *res == x )
  419. ptr.release();
  420. return iterator( res);
  421. }
  422. #ifndef BOOST_NO_AUTO_PTR
  423. template< class U >
  424. iterator insert( iterator where, std::auto_ptr<U> x )
  425. {
  426. return insert( where, x.release() );
  427. }
  428. #endif
  429. #ifndef BOOST_NO_CXX11_SMART_PTR
  430. template< class U >
  431. iterator insert( iterator where, std::unique_ptr<U> x )
  432. {
  433. return insert( where, x.release() );
  434. }
  435. #endif
  436. template< typename InputIterator >
  437. void insert( InputIterator first, InputIterator last ) // basic
  438. {
  439. set_basic_clone_and_insert( first, last );
  440. }
  441. #if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  442. #else
  443. template< class Range >
  444. BOOST_DEDUCED_TYPENAME
  445. boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
  446. insert( const Range& r )
  447. {
  448. insert( boost::begin(r), boost::end(r) );
  449. }
  450. #endif
  451. template< class PtrSetAdapter >
  452. bool transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator object,
  453. PtrSetAdapter& from ) // strong
  454. {
  455. return this->single_transfer( object, from );
  456. }
  457. template< class PtrSetAdapter >
  458. size_type
  459. transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator first,
  460. BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator last,
  461. PtrSetAdapter& from ) // basic
  462. {
  463. return this->single_transfer( first, last, from );
  464. }
  465. #if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  466. #else
  467. template< class PtrSetAdapter, class Range >
  468. BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
  469. BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator >,
  470. size_type >::type
  471. transfer( const Range& r, PtrSetAdapter& from ) // basic
  472. {
  473. return transfer( boost::begin(r), boost::end(r), from );
  474. }
  475. #endif
  476. template< class PtrSetAdapter >
  477. size_type transfer( PtrSetAdapter& from ) // basic
  478. {
  479. return transfer( from.begin(), from.end(), from );
  480. }
  481. };
  482. /////////////////////////////////////////////////////////////////////////
  483. // ptr_multiset_adapter
  484. /////////////////////////////////////////////////////////////////////////
  485. template
  486. <
  487. class Key,
  488. class VoidPtrMultiSet,
  489. class CloneAllocator = heap_clone_allocator,
  490. bool Ordered = true
  491. >
  492. class ptr_multiset_adapter :
  493. public ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrMultiSet,CloneAllocator,Ordered>
  494. {
  495. typedef ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrMultiSet,CloneAllocator,Ordered> base_type;
  496. public: // typedefs
  497. typedef BOOST_DEDUCED_TYPENAME base_type::iterator
  498. iterator;
  499. typedef BOOST_DEDUCED_TYPENAME base_type::size_type
  500. size_type;
  501. typedef Key key_type;
  502. typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
  503. auto_type;
  504. typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiSet::allocator_type
  505. allocator_type;
  506. private:
  507. template< typename II >
  508. void set_basic_clone_and_insert( II first, II last ) // basic
  509. {
  510. while( first != last )
  511. {
  512. insert( this->null_policy_allocate_clone_from_iterator( first ) ); // strong, commit
  513. ++first;
  514. }
  515. }
  516. public:
  517. ptr_multiset_adapter()
  518. { }
  519. template< class SizeType >
  520. ptr_multiset_adapter( SizeType n,
  521. ptr_container_detail::unordered_associative_container_tag tag )
  522. : base_type( n, tag )
  523. { }
  524. template< class Comp >
  525. explicit ptr_multiset_adapter( const Comp& comp,
  526. const allocator_type& a )
  527. : base_type( comp, a )
  528. { }
  529. template< class Hash, class Pred, class Allocator >
  530. ptr_multiset_adapter( const Hash& hash,
  531. const Pred& pred,
  532. const Allocator& a )
  533. : base_type( hash, pred, a )
  534. { }
  535. template< class InputIterator >
  536. ptr_multiset_adapter( InputIterator first, InputIterator last )
  537. : base_type( first, last )
  538. { }
  539. template< class InputIterator, class Comp >
  540. ptr_multiset_adapter( InputIterator first, InputIterator last,
  541. const Comp& comp,
  542. const allocator_type& a = allocator_type() )
  543. : base_type( comp, a )
  544. {
  545. set_basic_clone_and_insert( first, last );
  546. }
  547. template< class InputIterator, class Hash, class Pred, class Allocator >
  548. ptr_multiset_adapter( InputIterator first, InputIterator last,
  549. const Hash& hash,
  550. const Pred& pred,
  551. const Allocator& a )
  552. : base_type( first, last, hash, pred, a )
  553. { }
  554. template< class U, class Set, class CA, bool b >
  555. explicit ptr_multiset_adapter( const ptr_multiset_adapter<U,Set,CA,b>& r )
  556. : base_type( r )
  557. { }
  558. #ifndef BOOST_NO_AUTO_PTR
  559. template< class PtrContainer >
  560. explicit ptr_multiset_adapter( std::auto_ptr<PtrContainer> clone )
  561. : base_type( clone )
  562. { }
  563. #endif
  564. #ifndef BOOST_NO_CXX11_SMART_PTR
  565. template< class PtrContainer >
  566. explicit ptr_multiset_adapter( std::unique_ptr<PtrContainer> clone )
  567. : base_type( std::move( clone ) )
  568. { }
  569. #endif
  570. template< class U, class Set, class CA, bool b >
  571. ptr_multiset_adapter& operator=( const ptr_multiset_adapter<U,Set,CA,b>& r )
  572. {
  573. base_type::operator=( r );
  574. return *this;
  575. }
  576. #ifndef BOOST_NO_AUTO_PTR
  577. template< class T >
  578. void operator=( std::auto_ptr<T> r )
  579. {
  580. base_type::operator=( r );
  581. }
  582. #endif
  583. #ifndef BOOST_NO_CXX11_SMART_PTR
  584. template< class T >
  585. void operator=( std::unique_ptr<T> r )
  586. {
  587. base_type::operator=( std::move( r ) );
  588. }
  589. #endif
  590. iterator insert( iterator before, key_type* x ) // strong
  591. {
  592. return base_type::insert( before, x );
  593. }
  594. #ifndef BOOST_NO_AUTO_PTR
  595. template< class U >
  596. iterator insert( iterator before, std::auto_ptr<U> x )
  597. {
  598. return insert( before, x.release() );
  599. }
  600. #endif
  601. #ifndef BOOST_NO_CXX11_SMART_PTR
  602. template< class U >
  603. iterator insert( iterator before, std::unique_ptr<U> x )
  604. {
  605. return insert( before, x.release() );
  606. }
  607. #endif
  608. iterator insert( key_type* x ) // strong
  609. {
  610. this->enforce_null_policy( x, "Null pointer in 'ptr_multiset::insert()'" );
  611. auto_type ptr( x, *this );
  612. BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
  613. res = this->base().insert( x );
  614. ptr.release();
  615. return iterator( res );
  616. }
  617. #ifndef BOOST_NO_AUTO_PTR
  618. template< class U >
  619. iterator insert( std::auto_ptr<U> x )
  620. {
  621. return insert( x.release() );
  622. }
  623. #endif
  624. #ifndef BOOST_NO_CXX11_SMART_PTR
  625. template< class U >
  626. iterator insert( std::unique_ptr<U> x )
  627. {
  628. return insert( x.release() );
  629. }
  630. #endif
  631. template< typename InputIterator >
  632. void insert( InputIterator first, InputIterator last ) // basic
  633. {
  634. set_basic_clone_and_insert( first, last );
  635. }
  636. #if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  637. #else
  638. template< class Range >
  639. BOOST_DEDUCED_TYPENAME
  640. boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
  641. insert( const Range& r )
  642. {
  643. insert( boost::begin(r), boost::end(r) );
  644. }
  645. #endif
  646. template< class PtrSetAdapter >
  647. void transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator object,
  648. PtrSetAdapter& from ) // strong
  649. {
  650. this->multi_transfer( object, from );
  651. }
  652. template< class PtrSetAdapter >
  653. size_type transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator first,
  654. BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator last,
  655. PtrSetAdapter& from ) // basic
  656. {
  657. return this->multi_transfer( first, last, from );
  658. }
  659. #if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  660. #else
  661. template< class PtrSetAdapter, class Range >
  662. BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
  663. BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator >, size_type >::type
  664. transfer( const Range& r, PtrSetAdapter& from ) // basic
  665. {
  666. return transfer( boost::begin(r), boost::end(r), from );
  667. }
  668. #endif
  669. template< class PtrSetAdapter >
  670. void transfer( PtrSetAdapter& from ) // basic
  671. {
  672. transfer( from.begin(), from.end(), from );
  673. BOOST_ASSERT( from.empty() );
  674. }
  675. };
  676. } // namespace 'boost'
  677. #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
  678. #pragma GCC diagnostic pop
  679. #endif
  680. #endif