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
12#ifndef BOOST_PTR_CONTAINER_PTR_LIST_HPP
13#define BOOST_PTR_CONTAINER_PTR_LIST_HPP
14
15#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16# pragma once
17#endif
18
19#include <boost/ptr_container/ptr_sequence_adapter.hpp>
20#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
21#include <list>
22
23#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
26#endif
27
28namespace boost
29{
30
31 template
32 <
33 class T,
34 class CloneAllocator = heap_clone_allocator,
35 class Allocator = std::allocator<typename ptr_container_detail::void_ptr<T>::type>
36 >
37 class ptr_list : public
38 ptr_sequence_adapter< T, std::list<
39 typename ptr_container_detail::void_ptr<T>::type,Allocator>,
40 CloneAllocator >
41 {
42 typedef ptr_sequence_adapter< T, std::list<
43 typename ptr_container_detail::void_ptr<T>::type,Allocator>,
44 CloneAllocator >
45 base_class;
46
47 typedef ptr_list<T,CloneAllocator,Allocator> this_type;
48 typedef BOOST_DEDUCED_TYPENAME boost::remove_nullable<T>::type U;
49
50 public:
51 BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_list,
52 base_class,
53 this_type )
54
55 typedef BOOST_DEDUCED_TYPENAME base_class::value_type value_type;
56
57 public:
58 using base_class::merge;
59
60 void merge( ptr_list& x )
61 {
62 merge( x, std::less<U>() );
63 }
64
65 template< typename Compare >
66 void merge( ptr_list& x, Compare comp )
67 {
68 this->base().merge( x.base(), void_ptr_indirect_fun<Compare,U>( comp ) ); }
69
70 void sort()
71 {
72 sort( std::less<U>() );
73 };
74
75 template< typename Compare >
76 void sort( Compare comp )
77 {
78 this->base().sort( void_ptr_indirect_fun<Compare,U>( comp ) );
79 }
80
81 template< class Pred >
82 void erase_if( iterator first, iterator last, Pred pred )
83 {
84 base_class::erase_if( first, last, pred );
85 }
86
87 template< class Pred >
88 void erase_if( Pred pred )
89 {
90 this->base().remove_if( BOOST_DEDUCED_TYPENAME base_class::
91 BOOST_NESTED_TEMPLATE void_ptr_delete_if<Pred,value_type>
92 (pred) );
93 }
94
95 }; // class 'ptr_list'
96
97 //////////////////////////////////////////////////////////////////////////////
98 // clonability
99
100 template< typename T, typename CA, typename A >
101 inline ptr_list<T,CA,A>* new_clone( const ptr_list<T,CA,A>& r )
102 {
103 return r.clone().release();
104 }
105
106 /////////////////////////////////////////////////////////////////////////
107 // swap
108
109 template< typename T, typename CA, typename A >
110 inline void swap( ptr_list<T,CA,A>& l, ptr_list<T,CA,A>& r )
111 {
112 l.swap(r);
113 }
114}
115
116#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
117#pragma GCC diagnostic pop
118#endif
119
120#endif
121

source code of boost/libs/ptr_container/include/boost/ptr_container/ptr_list.hpp