diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:41:18 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:43:11 +0900 |
commit | f763a99a501650eff2c60288aa6f10ef916d769e (patch) | |
tree | 02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/container/deque.hpp | |
parent | 5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff) | |
download | boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2 boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip |
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/container/deque.hpp')
-rw-r--r-- | boost/container/deque.hpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/boost/container/deque.hpp b/boost/container/deque.hpp index fef28a124f..255cd9399d 100644 --- a/boost/container/deque.hpp +++ b/boost/container/deque.hpp @@ -535,7 +535,7 @@ class deque : protected deque_base<Allocator> //! <b>Throws</b>: If allocator_type's default constructor throws. //! //! <b>Complexity</b>: Constant. - deque() + deque() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value) : Base() {} @@ -707,7 +707,7 @@ class deque : protected deque_base<Allocator> //! <b>Throws</b>: If allocator_type's copy constructor throws. //! //! <b>Complexity</b>: Constant. - deque(BOOST_RV_REF(deque) x) + deque(BOOST_RV_REF(deque) x) BOOST_NOEXCEPT_OR_NOTHROW : Base(BOOST_MOVE_BASE(Base, x)) { this->swap_members(x); } @@ -1277,11 +1277,10 @@ class deque : protected deque_base<Allocator> return const_iterator(this->cbegin()+n); } - //! <b>Requires</b>: size() >= n. + //! <b>Requires</b>: begin() <= p <= end(). //! - //! <b>Effects</b>: Returns an iterator to the nth element - //! from the beginning of the container. Returns end() - //! if n == size(). + //! <b>Effects</b>: Returns the index of the element pointed by p + //! and size() if p == end(). //! //! <b>Throws</b>: Nothing. //! @@ -1349,44 +1348,52 @@ class deque : protected deque_base<Allocator> //! <b>Effects</b>: Inserts an object of type T constructed with //! std::forward<Args>(args)... in the beginning of the deque. //! + //! <b>Returns</b>: A reference to the created object. + //! //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. //! //! <b>Complexity</b>: Amortized constant time template <class... Args> - void emplace_front(BOOST_FWD_REF(Args)... args) + reference emplace_front(BOOST_FWD_REF(Args)... args) { if(this->priv_push_front_simple_available()){ + reference r = *this->priv_push_front_simple_pos(); allocator_traits_type::construct ( this->alloc() , this->priv_push_front_simple_pos() , boost::forward<Args>(args)...); this->priv_push_front_simple_commit(); + return r; } else{ typedef container_detail::insert_nonmovable_emplace_proxy<Allocator, iterator, Args...> type; - this->priv_insert_front_aux_impl(1, type(boost::forward<Args>(args)...)); + return *this->priv_insert_front_aux_impl(1, type(boost::forward<Args>(args)...)); } } //! <b>Effects</b>: Inserts an object of type T constructed with //! std::forward<Args>(args)... in the end of the deque. //! + //! <b>Returns</b>: A reference to the created object. + //! //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws. //! //! <b>Complexity</b>: Amortized constant time template <class... Args> - void emplace_back(BOOST_FWD_REF(Args)... args) + reference emplace_back(BOOST_FWD_REF(Args)... args) { if(this->priv_push_back_simple_available()){ + reference r = *this->priv_push_back_simple_pos(); allocator_traits_type::construct ( this->alloc() , this->priv_push_back_simple_pos() , boost::forward<Args>(args)...); this->priv_push_back_simple_commit(); + return r; } else{ typedef container_detail::insert_nonmovable_emplace_proxy<Allocator, iterator, Args...> type; - this->priv_insert_back_aux_impl(1, type(boost::forward<Args>(args)...)); + return *this->priv_insert_back_aux_impl(1, type(boost::forward<Args>(args)...)); } } @@ -1421,32 +1428,36 @@ class deque : protected deque_base<Allocator> #define BOOST_CONTAINER_DEQUE_EMPLACE_CODE(N) \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\ - void emplace_front(BOOST_MOVE_UREF##N)\ + reference emplace_front(BOOST_MOVE_UREF##N)\ {\ if(priv_push_front_simple_available()){\ + reference r = *this->priv_push_front_simple_pos();\ allocator_traits_type::construct\ ( this->alloc(), this->priv_push_front_simple_pos() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ priv_push_front_simple_commit();\ + return r;\ }\ else{\ typedef container_detail::insert_nonmovable_emplace_proxy##N\ <Allocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\ - priv_insert_front_aux_impl(1, type(BOOST_MOVE_FWD##N));\ + return *priv_insert_front_aux_impl(1, type(BOOST_MOVE_FWD##N));\ }\ }\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\ - void emplace_back(BOOST_MOVE_UREF##N)\ + reference emplace_back(BOOST_MOVE_UREF##N)\ {\ if(priv_push_back_simple_available()){\ + reference r = *this->priv_push_back_simple_pos();\ allocator_traits_type::construct\ ( this->alloc(), this->priv_push_back_simple_pos() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ priv_push_back_simple_commit();\ + return r;\ }\ else{\ typedef container_detail::insert_nonmovable_emplace_proxy##N\ <Allocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\ - priv_insert_back_aux_impl(1, type(BOOST_MOVE_FWD##N));\ + return *priv_insert_back_aux_impl(1, type(BOOST_MOVE_FWD##N));\ }\ }\ \ @@ -1712,16 +1723,14 @@ class deque : protected deque_base<Allocator> if (elems_before < (this->size() - n) - elems_before) { boost::container::move_backward(begin(), first.unconst(), last.unconst()); iterator new_start = this->members_.m_start + n; - if(!Base::traits_t::trivial_dctr_after_move) - this->priv_destroy_range(this->members_.m_start, new_start); + this->priv_destroy_range(this->members_.m_start, new_start); this->priv_destroy_nodes(this->members_.m_start.m_node, new_start.m_node); this->members_.m_start = new_start; } else { boost::container::move(last.unconst(), end(), first.unconst()); iterator new_finish = this->members_.m_finish - n; - if(!Base::traits_t::trivial_dctr_after_move) - this->priv_destroy_range(new_finish, this->members_.m_finish); + this->priv_destroy_range(new_finish, this->members_.m_finish); this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1); this->members_.m_finish = new_finish; } @@ -1828,8 +1837,7 @@ class deque : protected deque_base<Allocator> } else { iterator new_finish = this->members_.m_finish - n; - if(!Base::traits_t::trivial_dctr_after_move) - this->priv_destroy_range(new_finish, this->members_.m_finish); + this->priv_destroy_range(new_finish, this->members_.m_finish); this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1); this->members_.m_finish = new_finish; } |