16 class raw_queue final :
public std::queue<type_t, container_t> {
21 using base_type = std::queue<type_t, container_t>;
22 using container_type =
typename base_type::container_type;
23 using value_type =
typename base_type::value_type;
24 using size_type =
typename base_type::size_type;
25 using reference =
typename base_type::reference;
26 using const_reference =
typename base_type::const_reference;
27 using iterator =
typename container_type::const_iterator;
28 using const_iterator =
typename container_type::const_iterator;
34 raw_queue() {shrink_to_fit();}
35 explicit raw_queue(size_type capacity) {
37 ensure_capacity(capacity);
39 raw_queue(
const raw_queue&
other) : base_type(
other) {shrink_to_fit();}
40 raw_queue(raw_queue&&
other) : base_type(std::move(
other)) {shrink_to_fit();}
41 template<
class input_iterator_t>
42 raw_queue(input_iterator_t
first, input_iterator_t
last) : base_type(
first,
last) {shrink_to_fit();}
43 template<
class allocator_t>
44 explicit raw_queue(
const allocator_t& alloc) : base_type(alloc) {shrink_to_fit();}
45 template<
class allocator_t>
46 raw_queue(
const container_t& cont,
const allocator_t& alloc) : base_type(cont, alloc) {shrink_to_fit();}
47 template<
class allocator_t>
48 raw_queue(container_t&& cont,
const allocator_t& alloc) : base_type(std::move(cont), alloc) {shrink_to_fit();}
49 template<
class allocator_t >
50 raw_queue(
const raw_queue&
other,
const allocator_t& alloc) : base_type(
other, alloc) {shrink_to_fit();}
51 template<
class allocator_t >
52 raw_queue(raw_queue&&
other,
const allocator_t& alloc) : base_type(std::move(
other), alloc) {shrink_to_fit();}
53 template<
class input_iterator_t,
class allocator_t >
54 raw_queue(input_iterator_t
first, input_iterator_t
last,
const allocator_t& alloc) : base_type(
first,
last, alloc) {shrink_to_fit();}
60 auto items()
const noexcept ->
const base_type& {
return *
this;}
61 auto items()
noexcept -> base_type& {
return *
this;}
67 auto begin()
const -> const_iterator {
return base_type::c.cbegin();}
69 auto capacity()
const noexcept -> size_type {
return capacity_;}
71 auto cbegin()
const -> const_iterator {
return base_type::c.cbegin();}
73 auto cend()
const -> const_iterator {
return base_type::c.cend();}
75 auto end()
const -> const_iterator {
return base_type::c.cend();}
77 auto push(value_type&& value) ->
void {
78 base_type::push(std::move(value));
79 ensure_capacity(base_type::c.size());
82 auto pop() ->
void {base_type::pop();}
84 auto push(
const value_type& value) ->
void {
85 base_type::push(value);
86 ensure_capacity(base_type::c.size());
89 auto shrink_to_fit() ->
void {
90 base_type::c.shrink_to_fit();
91 ensure_capacity(base_type::c.size());
94 auto size()
const noexcept -> size_type {
return base_type::c.size();}
96 auto reserve(size_type count) ->
void {
97 if (capacity_ >= count)
return;
98 ensure_capacity(count);
105 raw_queue& operator =(
const raw_queue&
other) =
default;
106 raw_queue& operator =(raw_queue&&
other) =
default;
108 operator const base_type& ()
const noexcept {
return *
this;}
109 operator base_type& ()
noexcept {
return *
this;}
113 auto ensure_capacity(size_type capacity) ->
void {
114 if (capacity <= capacity_)
return;
115 capacity_ = capacity;
116 auto original_size = base_type::size();
117 base_type::c.resize(capacity_);
118 base_type::c.resize(original_size);
121 size_type capacity_ = base_type::size();
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307