@@ -76,13 +76,13 @@ class deque { | |||
//! @{ | |||
public: | |||
//! Default constructor | |||
deque () noexcept : | |||
constexpr deque () noexcept : | |||
data_{}, | |||
f{data_.data(), N}, | |||
r{data_.data()} { } | |||
//! fill contructor | |||
deque(const Data_t& value) noexcept { | |||
constexpr deque(const Data_t& value) noexcept { | |||
data_.fill(value); | |||
f = iterator(data_.data(), N); | |||
r = iterator(data_.data(), N); | |||
@@ -90,7 +90,7 @@ class deque { | |||
//! Initializer list contructor | |||
template <typename ...It> | |||
deque(It&& ...it) noexcept : | |||
constexpr deque(It&& ...it) noexcept : | |||
data_{{std::forward<It>(it)...}}, | |||
f(data_.data(), N), | |||
r(data_.data(), sizeof...(It)) { } | |||
@@ -103,38 +103,38 @@ class deque { | |||
//! \name Iterators | |||
//! @{ | |||
public: | |||
iterator begin() noexcept { return f+1; } | |||
const_iterator begin() const noexcept { return f+1; } | |||
const_iterator cbegin() const noexcept { return f+1; } | |||
constexpr iterator begin() noexcept { return f+1; } | |||
constexpr const_iterator begin() const noexcept { return f+1; } | |||
constexpr const_iterator cbegin() const noexcept { return f+1; } | |||
iterator end() noexcept { return r; } | |||
const_iterator end() const noexcept { return r; } | |||
const_iterator cend() const noexcept { return r; } | |||
constexpr iterator end() noexcept { return r; } | |||
constexpr const_iterator end() const noexcept { return r; } | |||
constexpr const_iterator cend() const noexcept { return r; } | |||
reverse_iterator rbegin() noexcept { return r; } | |||
const_reverse_iterator rbegin() const noexcept { return r; } | |||
const_reverse_iterator crbegin() const noexcept { return r; } | |||
constexpr reverse_iterator rbegin() noexcept { return r; } | |||
constexpr const_reverse_iterator rbegin() const noexcept { return r; } | |||
constexpr const_reverse_iterator crbegin() const noexcept { return r; } | |||
reverse_iterator rend() noexcept { return f+1; } | |||
const_reverse_iterator rend() const noexcept { return f+1; } | |||
const_reverse_iterator crend() const noexcept { return f+1; } | |||
constexpr reverse_iterator rend() noexcept { return f+1; } | |||
constexpr const_reverse_iterator rend() const noexcept { return f+1; } | |||
constexpr const_reverse_iterator crend() const noexcept { return f+1; } | |||
//! @} | |||
//! \name Capacity | |||
//! @{ | |||
public: | |||
//! \return The size of the deque. The items currently in queue. | |||
size_t size() noexcept { | |||
constexpr size_t size() noexcept { | |||
return full() ? N: (r - f) -1; | |||
} | |||
//! \return The maximum size of the deque. The items the queue can hold. | |||
size_t max_size() noexcept { return N; } | |||
constexpr size_t max_size() noexcept { return N; } | |||
//! \return The capacity of the deque. The items the queue can hold. | |||
size_t capacity() noexcept { return N; } | |||
constexpr size_t capacity() noexcept { return N; } | |||
//! \return True if the deque is empty | |||
bool empty() noexcept { return size() == 0 ? true : false; } | |||
constexpr bool empty() noexcept { return size() == 0 ? true : false; } | |||
//! \return True if the deque is full | |||
bool full() noexcept { return (r == f) ? true : false; } | |||
constexpr bool full() noexcept { return (r == f) ? true : false; } | |||
//! @} | |||
//! \name Member access | |||
@@ -142,44 +142,44 @@ class deque { | |||
public: | |||
//! \brief Clears-empty the deque and return it to init state, without | |||
//! really deleting the contents. | |||
void clear() noexcept { | |||
constexpr void clear() noexcept { | |||
f = iterator_t(data_.data(), N); | |||
r = iterator_t(data_.data()); | |||
} | |||
//! \brief Push an item in the front of the deque | |||
//! \param it The item to push | |||
void push_front (const Data_t& it) { | |||
constexpr void push_front (const Data_t& it) { | |||
if (full()) return; | |||
*f-- = it; | |||
} | |||
//! \brief Extract an item from the front of the deque and remove it from the deque | |||
//! \param it The item to push | |||
Data_t pop_front () { | |||
constexpr Data_t pop_front () { | |||
if (empty()) return Data_t{}; | |||
return *++f; | |||
} | |||
//! \brief Push an item in the back of the deque | |||
//! \param it The item to push | |||
void push_back (const Data_t& it) { | |||
constexpr void push_back (const Data_t& it) { | |||
if (full()) return; | |||
*r++ = it; | |||
} | |||
//! \brief Extract an item from the back of the deque and remove it from the deque | |||
//! \param it The item to push | |||
Data_t pop_back () { | |||
constexpr Data_t pop_back () { | |||
if (empty()) return Data_t{}; | |||
return *--r; | |||
} | |||
//! \brief Get a reference to the item in the front of the deque without extracting it. | |||
//! \return Reference to the item | |||
Data_t& front() noexcept { return *(f+1); } | |||
const Data_t& front() const noexcept { return *(f+1); } | |||
constexpr Data_t& front() noexcept { return *(f+1); } | |||
constexpr const Data_t& front() const noexcept { return *(f+1); } | |||
//! \brief Get a reference to the item in the front of the deque without extracting it. | |||
//! \return Reference to the item | |||
Data_t& back() noexcept { return *(r-1); } | |||
const Data_t& back() const noexcept { return *(r-1); } | |||
constexpr Data_t& back() noexcept { return *(r-1); } | |||
constexpr const Data_t& back() const noexcept { return *(r-1); } | |||
//! @} | |||
private: | |||
@@ -117,11 +117,11 @@ class edeque : public deque<Data_t, N> { | |||
//! @{ | |||
public: | |||
//! Default constructor | |||
edeque () noexcept : | |||
constexpr edeque () noexcept : | |||
base_type() { } | |||
//! | |||
edeque (size_match match, size_t size, callable_t&& fn) : | |||
constexpr edeque (size_match match, size_t size, callable_t&& fn) : | |||
base_type(), | |||
mode_{match_mode::SIZE}, | |||
callback_{std::forward<callable_t>(fn)} { | |||
@@ -129,7 +129,7 @@ class edeque : public deque<Data_t, N> { | |||
trigger_.tsize.size = size; | |||
} | |||
edeque (data_match match, Data_t value, callable_t&& fn) : | |||
constexpr edeque (data_match match, Data_t value, callable_t&& fn) : | |||
base_type(), | |||
mode_{match_mode::DATA}, | |||
callback_{std::forward<callable_t>(fn)} { | |||
@@ -73,14 +73,14 @@ class queue : public deque<Data_t, N> { | |||
//! @{ | |||
public: | |||
//! Default constructor | |||
queue () noexcept : base_type() { } | |||
constexpr queue () noexcept : base_type() { } | |||
//! fill contructor | |||
queue(const Data_t& value) noexcept : base_type(value) { } | |||
constexpr queue(const Data_t& value) noexcept : base_type(value) { } | |||
//! Initializer list contructor | |||
template <typename ...It> | |||
queue(It&& ...it) noexcept : base_type(std::forward<It>(it)...) { } | |||
constexpr queue(It&& ...it) noexcept : base_type(std::forward<It>(it)...) { } | |||
//! @} | |||
@@ -58,16 +58,16 @@ class ring_iterator { | |||
//! \name Constructor / Destructor | |||
//! @{ | |||
public: | |||
ring_iterator(const Iter_t base =nullptr) noexcept : | |||
constexpr ring_iterator(const Iter_t base =nullptr) noexcept : | |||
base_(base), iter_(base) { } | |||
ring_iterator(const Iter_t base, size_t elem) noexcept : | |||
constexpr ring_iterator(const Iter_t base, size_t elem) noexcept : | |||
base_(base), iter_(base + elem) { } | |||
ring_iterator(const ring_iterator& it) noexcept : | |||
constexpr ring_iterator(const ring_iterator& it) noexcept : | |||
base_(it.base_), iter_(it.iter_) { } | |||
ring_iterator& operator= (const ring_iterator& it) noexcept { | |||
constexpr ring_iterator& operator= (const ring_iterator& it) noexcept { | |||
base_ = it.base_; | |||
iter_ = it.iter_; | |||
return *this; | |||
@@ -77,18 +77,21 @@ class ring_iterator { | |||
//! \name Forward iterator requirements | |||
//! @{ | |||
public: | |||
reference operator*() const noexcept { | |||
constexpr reference operator*() const noexcept { | |||
return *iter_; | |||
} | |||
pointer operator->() const noexcept { | |||
constexpr pointer operator->() const noexcept { | |||
return iter_; | |||
} | |||
ring_iterator& operator++() noexcept { | |||
constexpr ring_iterator& operator++() noexcept { | |||
if (static_cast<size_t>(++iter_ - base_) >= N) | |||
iter_ = base_; | |||
return *this; | |||
} | |||
ring_iterator operator++(int) noexcept { | |||
constexpr ring_iterator operator++(int) noexcept { | |||
ring_iterator it = *this; | |||
if (static_cast<size_t>(++iter_ - base_) >= N) | |||
iter_ = base_; | |||
@@ -99,12 +102,12 @@ class ring_iterator { | |||
//! \name Bidirectional iterator requirements | |||
//! @{ | |||
public: | |||
ring_iterator& operator--() noexcept { | |||
constexpr ring_iterator& operator--() noexcept { | |||
if (--iter_ < base_) | |||
iter_ = base_ + N -1; | |||
return *this; | |||
} | |||
ring_iterator operator--(int) noexcept { | |||
constexpr ring_iterator operator--(int) noexcept { | |||
ring_iterator it = *this; | |||
if (--iter_ < base_) | |||
iter_ = base_ + N -1; | |||
@@ -114,33 +117,34 @@ class ring_iterator { | |||
//! \name Random access iterator requirements | |||
//! @{ | |||
reference operator[](difference_type n) const noexcept { | |||
constexpr reference operator[](difference_type n) const noexcept { | |||
difference_type k = iter_ - base_; // ptrdiff from base_ | |||
return (static_cast<size_t>(k + n) < N) ? | |||
base_[k + n] : // on range | |||
base_[k + n - N]; // out of range, loop | |||
} | |||
ring_iterator& operator+=(difference_type n) noexcept { | |||
constexpr ring_iterator& operator+=(difference_type n) noexcept { | |||
difference_type k = iter_ - base_; // ptrdiff from base_ | |||
iter_ += (static_cast<size_t>(k + n) < N) ? | |||
n : // on range | |||
n - N; // out of range, loop | |||
return *this; | |||
} | |||
ring_iterator operator+(difference_type n) const noexcept { | |||
constexpr ring_iterator operator+(difference_type n) const noexcept { | |||
difference_type k = iter_ - base_; // ptrdiff from base_ | |||
return (static_cast<size_t>(k + n) < N) ? | |||
ring_iterator(base_, k + n) : // on range | |||
ring_iterator(base_, k + n - N); // out of range, loop | |||
} | |||
ring_iterator& operator-=(difference_type n) noexcept { | |||
constexpr ring_iterator& operator-=(difference_type n) noexcept { | |||
difference_type k = iter_ - base_; // ptrdiff from base_ | |||
iter_ -= ((k - n) < 0)? | |||
n - N: // out of range, loop | |||
n; // on range | |||
return *this; | |||
} | |||
ring_iterator operator-(difference_type n) const noexcept { | |||
constexpr ring_iterator operator-(difference_type n) const noexcept { | |||
difference_type k = iter_ - base_; // ptrdiff from base_ | |||
return ((k - n) < 0) ? | |||
ring_iterator(base_, k - n + N) : // out of range, loop | |||
@@ -150,13 +154,13 @@ class ring_iterator { | |||
//! \name Data members and access | |||
//! @{ | |||
const Iter_t& base() const noexcept { | |||
constexpr const Iter_t& base() const noexcept { | |||
return base_; | |||
} | |||
const Iter_t& iter() const noexcept { | |||
constexpr const Iter_t& iter() const noexcept { | |||
return iter_; | |||
} | |||
size_t size() noexcept { | |||
constexpr size_t size() noexcept { | |||
return N; | |||
} | |||