comparison DEPENDENCIES/generic/include/boost/thread/csbl/devector.hpp @ 102:f46d142149f5

Whoops, finish that update
author Chris Cannam
date Mon, 07 Sep 2015 11:13:41 +0100
parents
children
comparison
equal deleted inserted replaced
101:c530137014c0 102:f46d142149f5
1 // Copyright (C) 2013 Vicente J. Botet Escriba
2 //
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)
5 //
6 // 2013/10 Vicente J. Botet Escriba
7 // Creation.
8
9 #ifndef BOOST_CSBL_DEVECTOR_HPP
10 #define BOOST_CSBL_DEVECTOR_HPP
11
12 #include <boost/config.hpp>
13
14 #include <boost/thread/csbl/vector.hpp>
15 #include <boost/move/detail/move_helpers.hpp>
16
17 namespace boost
18 {
19 namespace csbl
20 {
21 template <class T>
22 class devector
23 {
24 typedef vector<T> vector_type;
25 vector<T> data_;
26 std::size_t front_index_;
27
28 BOOST_COPYABLE_AND_MOVABLE(devector)
29
30 template <class U>
31 void priv_push_back(BOOST_FWD_REF(U) x)
32 { data_.push_back(boost::forward<U>(x)); }
33
34 public:
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;
38
39
40 devector() : front_index_(0) {}
41 devector(devector const& x) BOOST_NOEXCEPT
42 : data_(x.data_),
43 front_index_(x.front_index_)
44 {}
45 devector(BOOST_RV_REF(devector) x) BOOST_NOEXCEPT
46 : data_(boost::move(x.data_)),
47 front_index_(x.front_index_)
48 {}
49
50 devector& operator=(BOOST_COPY_ASSIGN_REF(devector) x)
51 {
52 if (&x != this)
53 {
54 data_ = x.data_;
55 front_index_ = x.front_index_;
56 }
57 return *this;
58 }
59
60 devector& operator=(BOOST_RV_REF(devector) x)
61 BOOST_NOEXCEPT_IF(vector<T>::allocator_traits_type::propagate_on_container_move_assignment::value)
62 {
63 data_ = boost::move(x.data_);
64 front_index_ = x.front_index_;
65 return *this;
66 }
67
68 bool empty() const BOOST_NOEXCEPT
69 { return data_.size() == front_index_; }
70
71 size_type size() const BOOST_NOEXCEPT
72 { return data_.size() - front_index_; }
73
74 reference front() BOOST_NOEXCEPT
75 { return data_[front_index_]; }
76
77 const_reference front() const BOOST_NOEXCEPT
78 { return data_[front_index_]; }
79
80 reference back() BOOST_NOEXCEPT
81 { return data_.back(); }
82
83 const_reference back() const BOOST_NOEXCEPT
84 { return data_.back(); }
85
86 BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
87
88 void pop_front()
89 {
90 ++front_index_;
91 if (empty()) {
92 data_.clear();
93 front_index_=0;
94 }
95 }
96
97 };
98 }
99 }
100 #endif // header