OGS
DynamicSpan.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <cstddef>
13
14namespace BaseLib
15{
16template <typename T>
18{
19 template <typename Iterator>
20 DynamicSpan(Iterator data_, std::size_t size)
21 : data{&*data_ /* manually convert iterator to pointer */}, size_{size}
22 {
23 }
24
25 T* begin() const { return data; }
26 T* end() const { return data + size_; }
27 std::size_t size() const { return size_; }
28 T& operator[](std::size_t i) const { return data[i]; }
29
30 T* data;
31
32private:
33 std::size_t size_;
34};
35
36template <typename T>
37DynamicSpan(T*, std::size_t) -> DynamicSpan<T>;
38} // namespace BaseLib
DynamicSpan(T *, std::size_t) -> DynamicSpan< T >
DynamicSpan(Iterator data_, std::size_t size)
Definition: DynamicSpan.h:20
T * begin() const
Definition: DynamicSpan.h:25
T & operator[](std::size_t i) const
Definition: DynamicSpan.h:28
std::size_t size() const
Definition: DynamicSpan.h:27
std::size_t size_
Definition: DynamicSpan.h:33