File indexing completed on 2025-01-30 10:01:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_CSBL_DEVECTOR_HPP
0010 #define BOOST_CSBL_DEVECTOR_HPP
0011
0012 #include <boost/config.hpp>
0013
0014 #include <boost/thread/csbl/vector.hpp>
0015 #include <boost/move/detail/move_helpers.hpp>
0016
0017 namespace boost
0018 {
0019 namespace csbl
0020 {
0021 template <class T>
0022 class devector
0023 {
0024 typedef csbl::vector<T> vector_type;
0025 vector_type data_;
0026 std::size_t front_index_;
0027
0028 BOOST_COPYABLE_AND_MOVABLE(devector)
0029
0030 template <class U>
0031 void priv_push_back(BOOST_FWD_REF(U) x)
0032 { data_.push_back(boost::forward<U>(x)); }
0033
0034 public:
0035 typedef typename vector_type::size_type size_type;
0036 typedef typename vector_type::reference reference;
0037 typedef typename vector_type::const_reference const_reference;
0038
0039
0040 devector() : front_index_(0) {}
0041 devector(devector const& x) BOOST_NOEXCEPT
0042 : data_(x.data_),
0043 front_index_(x.front_index_)
0044 {}
0045 devector(BOOST_RV_REF(devector) x) BOOST_NOEXCEPT
0046 : data_(boost::move(x.data_)),
0047 front_index_(x.front_index_)
0048 {}
0049
0050 devector& operator=(BOOST_COPY_ASSIGN_REF(devector) x)
0051 {
0052 if (&x != this)
0053 {
0054 data_ = x.data_;
0055 front_index_ = x.front_index_;
0056 }
0057 return *this;
0058 }
0059
0060 devector& operator=(BOOST_RV_REF(devector) x)
0061 #if defined BOOST_THREAD_USES_BOOST_VECTOR
0062 BOOST_NOEXCEPT_IF(vector_type::allocator_traits_type::propagate_on_container_move_assignment::value)
0063 #endif
0064 {
0065 data_ = boost::move(x.data_);
0066 front_index_ = x.front_index_;
0067 return *this;
0068 }
0069
0070 bool empty() const BOOST_NOEXCEPT
0071 { return data_.size() == front_index_; }
0072
0073 size_type size() const BOOST_NOEXCEPT
0074 { return data_.size() - front_index_; }
0075
0076 reference front() BOOST_NOEXCEPT
0077 { return data_[front_index_]; }
0078
0079 const_reference front() const BOOST_NOEXCEPT
0080 { return data_[front_index_]; }
0081
0082 reference back() BOOST_NOEXCEPT
0083 { return data_.back(); }
0084
0085 const_reference back() const BOOST_NOEXCEPT
0086 { return data_.back(); }
0087
0088 BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
0089
0090 void pop_front()
0091 {
0092 ++front_index_;
0093 if (empty()) {
0094 data_.clear();
0095 front_index_=0;
0096 }
0097 }
0098
0099 };
0100 }
0101 }
0102 #endif