1 // Copyright (C) 2013 Vicente J. Botet Escriba
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 // 2013/10 Vicente J. Botet Escriba
9 #ifndef BOOST_CSBL_DEVECTOR_HPP
10 #define BOOST_CSBL_DEVECTOR_HPP
12 #include <boost/config.hpp>
14 #include <boost/thread/csbl/vector.hpp>
15 #include <boost/move/detail/move_helpers.hpp>
24 typedef csbl::vector<T> vector_type;
26 std::size_t front_index_;
28 BOOST_COPYABLE_AND_MOVABLE(devector)
31 void priv_push_back(BOOST_FWD_REF(U) x)
32 { data_.push_back(boost::forward<U>(x)); }
35 typedef typename vector_type::size_type size_type;
36 typedef typename vector_type::reference reference;
37 typedef typename vector_type::const_reference const_reference;
40 devector() : front_index_(0) {}
41 devector(devector const& x) BOOST_NOEXCEPT
43 front_index_(x.front_index_)
45 devector(BOOST_RV_REF(devector) x) BOOST_NOEXCEPT
46 : data_(boost::move(x.data_)),
47 front_index_(x.front_index_)
50 devector& operator=(BOOST_COPY_ASSIGN_REF(devector) x)
55 front_index_ = x.front_index_;
60 devector& operator=(BOOST_RV_REF(devector) x)
61 #if defined BOOST_THREAD_USES_BOOST_VECTOR
62 BOOST_NOEXCEPT_IF(vector_type::allocator_traits_type::propagate_on_container_move_assignment::value)
65 data_ = boost::move(x.data_);
66 front_index_ = x.front_index_;
70 bool empty() const BOOST_NOEXCEPT
71 { return data_.size() == front_index_; }
73 size_type size() const BOOST_NOEXCEPT
74 { return data_.size() - front_index_; }
76 reference front() BOOST_NOEXCEPT
77 { return data_[front_index_]; }
79 const_reference front() const BOOST_NOEXCEPT
80 { return data_[front_index_]; }
82 reference back() BOOST_NOEXCEPT
83 { return data_.back(); }
85 const_reference back() const BOOST_NOEXCEPT
86 { return data_.back(); }
88 BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)