diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
commit | b8cf34c691623e4ec329053cbbf68522a855882d (patch) | |
tree | 34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/ptr_container/ptr_array.hpp | |
parent | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff) | |
download | boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2 boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip |
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/ptr_container/ptr_array.hpp')
-rw-r--r-- | boost/ptr_container/ptr_array.hpp | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/boost/ptr_container/ptr_array.hpp b/boost/ptr_container/ptr_array.hpp index 6bddb73375..cf9d4d4f01 100644 --- a/boost/ptr_container/ptr_array.hpp +++ b/boost/ptr_container/ptr_array.hpp @@ -19,6 +19,12 @@ #include <boost/array.hpp> #include <boost/static_assert.hpp> #include <boost/ptr_container/ptr_sequence_adapter.hpp> +#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp> + +#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif namespace boost { @@ -102,8 +108,14 @@ namespace boost static_cast<const T*>( &r[i] ) ); } +#ifndef BOOST_NO_AUTO_PTR explicit ptr_array( std::auto_ptr<this_type> r ) : base_class( r ) { } +#endif +#ifndef BOOST_NO_CXX11_SMART_PTR + explicit ptr_array( std::unique_ptr<this_type> r ) + : base_class( std::move( r ) ) { } +#endif ptr_array& operator=( ptr_array r ) { @@ -111,12 +123,22 @@ namespace boost return *this; } +#ifndef BOOST_NO_AUTO_PTR ptr_array& operator=( std::auto_ptr<this_type> r ) { base_class::operator=(r); return *this; } +#endif +#ifndef BOOST_NO_CXX11_SMART_PTR + ptr_array& operator=( std::unique_ptr<this_type> r ) + { + base_class::operator=(std::move(r)); + return *this; + } +#endif +#ifndef BOOST_NO_AUTO_PTR std::auto_ptr<this_type> release() { std::auto_ptr<this_type> ptr( new this_type ); @@ -127,12 +149,32 @@ namespace boost std::auto_ptr<this_type> clone() const { std::auto_ptr<this_type> pa( new this_type ); + clone_array_elements( *pa ); + return pa; + } +#else + std::unique_ptr<this_type> release() + { + std::unique_ptr<this_type> ptr( new this_type ); + this->swap( *ptr ); + return ptr; + } + + std::unique_ptr<this_type> clone() const + { + std::unique_ptr<this_type> pa( new this_type ); + clone_array_elements( *pa ); + return pa; + } +#endif + private: + void clone_array_elements( this_type &pa ) const + { for( size_t i = 0; i != N; ++i ) { if( !this->is_null(i) ) - pa->replace( i, pa->null_policy_allocate_clone( &(*this)[i] ) ); + pa.replace( i, pa.null_policy_allocate_clone( &(*this)[i] ) ); } - return pa; } private: // hide some members @@ -158,11 +200,20 @@ namespace boost return boost::ptr_container::move(res); // nothrow } +#ifndef BOOST_NO_AUTO_PTR template< size_t idx, class V > auto_type replace( std::auto_ptr<V> r ) { return replace<idx>( r.release() ); } +#endif +#ifndef BOOST_NO_CXX11_SMART_PTR + template< size_t idx, class V > + auto_type replace( std::unique_ptr<V> r ) + { + return replace<idx>( r.release() ); + } +#endif auto_type replace( size_t idx, U* r ) // strong { @@ -177,11 +228,20 @@ namespace boost return boost::ptr_container::move(res); // nothrow } +#ifndef BOOST_NO_AUTO_PTR template< class V > auto_type replace( size_t idx, std::auto_ptr<V> r ) { return replace( idx, r.release() ); } +#endif +#ifndef BOOST_NO_CXX11_SMART_PTR + template< class V > + auto_type replace( size_t idx, std::unique_ptr<V> r ) + { + return replace( idx, r.release() ); + } +#endif using base_class::at; @@ -231,4 +291,8 @@ namespace boost } } +#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED) +#pragma GCC diagnostic pop +#endif + #endif |