MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / ArrayView

Class ArrayView

Sources/Shared/Containers/ArrayView.h:133–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 @endcode
132 */
133 template<class T> class ArrayView
134 {
135 public:
136 /** @brief Element type */
137 typedef T Type;
138
139 /**
140 * @brief Default constructor
141 *
142 * Creates an empty @cpp nullptr @ce view. Copy a non-empty @ref Array
143 * or @ref ArrayView onto the instance to make it useful.
144 */
145#ifdef DOXYGEN_GENERATING_OUTPUT
146 constexpr /*implicit*/ ArrayView(std::nullptr_t = nullptr) noexcept;
147#else
148 /* To avoid ambiguity in certain cases of passing 0 to overloads that take either an ArrayView or std::size_t */
149 template<class U, typename std::enable_if<std::is_same<std::nullptr_t, U>::value, int>::type = 0> constexpr /*implicit*/ ArrayView(U) noexcept : _data{}, _size{} {}
150
151 constexpr /*implicit*/ ArrayView() noexcept : _data{}, _size{} {}
152#endif
153
154 /**
155 * @brief Construct a view on an array with explicit size
156 * @param data Data pointer
157 * @param size Data size
158 */
159 constexpr /*implicit*/ ArrayView(T* data, std::size_t size) noexcept : _data(data), _size(size) {}
160
161 /**
162 * @brief Construct a view on a fixed-size array
163 * @param data Fixed-size array
164 *
165 * Enabled only if @cpp T* @ce is implicitly convertible to @cpp U* @ce.
166 * Expects that both types have the same size.
167 */
168 template<class U, std::size_t size
169#ifndef DOXYGEN_GENERATING_OUTPUT
170 , typename std::enable_if<std::is_convertible<U*, T*>::value, int>::type = 0
171#endif
172 > constexpr /*implicit*/ ArrayView(U(&data)[size]) noexcept : _data{data}, _size{size} {
173 static_assert(sizeof(T) == sizeof(U), "Type sizes are not compatible");
174 }
175
176 /**
177 * @brief Construct a view on an @ref ArrayView
178 *
179 * Enabled only if @cpp T* @ce is implicitly convertible to @cpp U* @ce.
180 * Expects that both types have the same size.
181 */
182 template<class U
183#ifndef DOXYGEN_GENERATING_OUTPUT
184 , typename std::enable_if<std::is_convertible<U*, T*>::value, int>::type = 0
185#endif
186 > constexpr /*implicit*/ ArrayView(ArrayView<U> view) noexcept : _data{view}, _size{view.size()} {
187 static_assert(sizeof(T) == sizeof(U), "Type sizes are not compatible");
188 }
189
190 /**

Callers 6

UpdatePressedActionsMethod · 0.50
GetMappingsMethod · 0.50
UpdatePressedActionsMethod · 0.50
UpdatePressedActionsMethod · 0.50
UpdatePressedActionsMethod · 0.50
UpdatePressedActionsMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected