File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/openvic-simulation/types Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < span>
4+
5+ #include < type_safe/strong_typedef.hpp>
6+
7+ #include " openvic-simulation/utility/Concepts.hpp"
8+ #include " openvic-simulation/utility/ForwardableSpan.hpp"
9+
10+ namespace OpenVic {
11+ template <
12+ derived_from_specialization_of<type_safe::strong_typedef> IndexType,
13+ typename ValueType,
14+ size_t _Extent = std::dynamic_extent
15+ >
16+ struct TypedSpan : public utility ::forwardable_span<ValueType, _Extent> {
17+ public:
18+ using utility::forwardable_span<ValueType, _Extent>::forwardable_span;
19+
20+ constexpr IndexType size () const {
21+ return IndexType (std::span<ValueType, _Extent>::size ());
22+ }
23+
24+ constexpr utility::forwardable_span<ValueType, _Extent>::reference operator [](const IndexType _Off) const {
25+ return utility::forwardable_span<ValueType, _Extent>::operator [](static_cast <std::size_t >(type_safe::get (_Off)));
26+ }
27+
28+ constexpr operator TypedSpan<IndexType, const ValueType, _Extent>() {
29+ return TypedSpan<IndexType, const ValueType, _Extent>{*this };
30+ }
31+ };
32+ }
You can’t perform that action at this time.
0 commit comments