AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
FakeContainer.hpp
1#pragma once
2
3#include <cstddef>
4#include <iterator>
5
6namespace AMDiS
7{
9 {
10 template <class T>
11 constexpr FakeAssigner& operator=(T&&) noexcept { return *this; }
12
13 template <class T>
14 constexpr FakeAssigner& operator+=(T&&) noexcept { return *this; }
15
16 template <class T>
17 constexpr FakeAssigner& operator-=(T&&) noexcept { return *this; }
18
19 template <class T>
20 constexpr FakeAssigner& operator*=(T&&) noexcept { return *this; }
21
22 template <class T>
23 constexpr FakeAssigner& operator/=(T&&) noexcept { return *this; }
24 };
25
28
33 template <class T, T value>
35 : public FakeAssigner
36 {
37 public:
38 using value_type = T;
39 using size_type = std::size_t;
40
42 {
43 using value_type = T;
44 using reference = T;
45 using difference_type = std::ptrdiff_t;
46 using iterator_category = std::forward_iterator_tag;
47
48 constexpr T operator*() const noexcept { return value; }
49 constexpr const_iterator& operator++() noexcept { return *this; }
50 constexpr const_iterator operator++(int) noexcept { return *this; }
51
53 constexpr bool operator==(const_iterator) const noexcept { return true; }
54 constexpr bool operator!=(const_iterator) const noexcept { return false; }
55 };
56
57
58 public: // constructor
59
60 template <class... Args>
61 constexpr explicit FakeContainer(Args&&...) noexcept {}
62
63 template <class S>
64 constexpr void init(S const&, bool) noexcept { /* do nothing */ }
65 constexpr void finish() noexcept { /* do nothing */ }
66
67
68 public: // modifiers and capacity
69
70 template <class... Args>
71 constexpr void scatter(Args&&...) noexcept { /* do nothing */ }
72
73 template <class Arg>
74 constexpr void push_back(Arg&&) noexcept { /* do nothing */ }
75
76 template <class... Args>
77 constexpr void emplace_back(Args&&...) noexcept { /* do nothing */ }
78
79 template <class Size>
80 constexpr void reserve(Size&&) noexcept { /* do nothing */ }
81
82 template <class Size>
83 constexpr void resize(Size&&) noexcept { /* do nothing */ }
84
86 constexpr bool empty() const noexcept { return false; }
87
88
89 public: // element access
90
93 template <class Index>
94 constexpr FakeContainer& operator[](Index&&) noexcept { return *this; }
95
98 template <class Index>
99 constexpr FakeContainer const& operator[](Index&&) const noexcept { return *this; }
100
102 template <class Index>
103 constexpr FakeContainer& at(Index&&) noexcept { return *this; }
104
106 template <class Index>
107 constexpr FakeContainer const& at(Index&&) const noexcept { return *this; }
108
109
110 constexpr FakeContainer& front() noexcept { return *this; }
111 constexpr FakeContainer const& front() const noexcept { return *this; }
112
113
115 constexpr operator T() const noexcept { return value; }
116
117
118 public: // iterators
119
121 constexpr const_iterator begin() const noexcept { return const_iterator{}; }
122
124 constexpr const_iterator cbegin() const noexcept { return const_iterator{}; }
125
126
127 public: // assignment operators
128
130 using FakeAssigner::operator=;
131 using FakeAssigner::operator+=;
132 using FakeAssigner::operator-=;
133 using FakeAssigner::operator*=;
134 using FakeAssigner::operator/=;
135 };
136
137} // end namespace AMDiS
A container-like data-structure not storing anything and with empty implementations in many container...
Definition: FakeContainer.hpp:36
constexpr const_iterator begin() const noexcept
Return iterator that always redirects to a bool true.
Definition: FakeContainer.hpp:121
constexpr FakeContainer & operator[](Index &&) noexcept
Definition: FakeContainer.hpp:94
constexpr FakeContainer const & at(Index &&) const noexcept
Const element access.
Definition: FakeContainer.hpp:107
constexpr FakeContainer & at(Index &&) noexcept
Mutable element access.
Definition: FakeContainer.hpp:103
constexpr const_iterator cbegin() const noexcept
Return iterator that always redirects to a bool true.
Definition: FakeContainer.hpp:124
constexpr FakeContainer const & operator[](Index &&) const noexcept
Definition: FakeContainer.hpp:99
constexpr bool empty() const noexcept
This container is never empty.
Definition: FakeContainer.hpp:86
Definition: FakeContainer.hpp:9
Definition: FakeContainer.hpp:42
constexpr bool operator==(const_iterator) const noexcept
Comparison of the iterator is always true.
Definition: FakeContainer.hpp:53