11 #ifndef __JSONV_DETAIL_GENERIC_CONTAINER_HPP_INCLUDED__ 12 #define __JSONV_DETAIL_GENERIC_CONTAINER_HPP_INCLUDED__ 17 #include <initializer_list> 28 template <
typename TStorage>
32 using storage_type = TStorage;
33 using size_type =
typename storage_type::size_type;
34 using value_type =
typename storage_type::value_type;
35 using difference_type =
typename storage_type::difference_type;
36 using iterator =
typename storage_type::iterator;
37 using const_iterator =
typename storage_type::const_iterator;
38 using reverse_iterator =
typename storage_type::reverse_iterator;
39 using const_reverse_iterator =
typename storage_type::const_reverse_iterator;
40 using reference =
typename storage_type::reference;
41 using const_reference =
typename storage_type::const_reference;
42 using pointer =
typename storage_type::pointer;
43 using const_pointer =
typename storage_type::const_pointer;
44 using allocator_type =
typename storage_type::allocator_type;
51 _data(std::move(data))
54 template <
typename TInputIterator>
65 size_type
size()
const {
return _data.size(); }
67 bool empty()
const {
return _data.empty(); }
69 iterator begin() {
return _data.begin(); }
70 const_iterator begin()
const {
return _data.begin(); }
71 const_iterator cbegin()
const {
return _data.begin(); }
73 iterator end() {
return _data.end(); }
74 const_iterator end()
const {
return _data.end(); }
75 const_iterator cend()
const {
return _data.end(); }
77 reverse_iterator rbegin() {
return _data.rbegin(); }
78 const_reverse_iterator rbegin()
const {
return _data.rbegin(); }
79 const_reverse_iterator crbegin()
const {
return _data.rbegin(); }
81 reverse_iterator rend() {
return _data.rend(); }
82 const_reverse_iterator rend()
const {
return _data.rend(); }
83 const_reverse_iterator crend()
const {
return _data.rend(); }
85 reference operator[](size_type idx) {
return _data[idx]; }
86 const_reference operator[](size_type idx)
const {
return _data[idx]; }
88 reference at(size_type idx) {
return _data.at(idx); }
89 const_reference at(size_type idx)
const {
return _data.at(idx); }
91 reference front() {
return _data.front(); }
92 const_reference front()
const {
return _data.front(); }
94 reference back() {
return _data.back(); }
95 const_reference back()
const {
return _data.back(); }
97 void clear() {
return _data.clear(); }
99 iterator insert(const_iterator pos,
const value_type& x) {
return _data.insert(pos, x); }
100 iterator insert(const_iterator pos, value_type&& x) {
return _data.insert(pos, std::move(x)); }
102 template <
typename TInputIterator>
103 iterator insert(const_iterator pos, TInputIterator first, TInputIterator last)
105 return _data.insert(pos, first, last);
108 iterator insert(const_iterator pos, std::initializer_list<value_type> ilist)
110 return _data.insert(pos, ilist);
113 template <
typename... TArgs>
114 iterator emplace(const_iterator pos, TArgs&&... args)
116 return _data.emplace(pos, std::forward<TArgs>(args)...);
119 template <
typename... TArgs>
120 void emplace_back(TArgs&&... args)
122 return _data.emplace_back(std::forward<TArgs>(args)...);
125 void push_back(
const value_type& x) {
return _data.push_back(x); }
126 void push_back(value_type&& x) {
return _data.push_back(std::move(x)); }
128 iterator erase(const_iterator pos) {
return _data.erase(pos); }
129 iterator erase(const_iterator first, const_iterator last) {
return _data.erase(first, last); }
131 void pop_back() {
return _data.pop_back(); }
137 template <
typename TStorage>
145 return std::equal(a.begin(), a.end(), b.begin());
148 template <
typename TStorage>
Copyright (c) 2014-2019 by Travis Gockel.
size_type size() const
Get the number of elements.
A generic container that exposes the traversal and modification operations externally.