File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
src/openvic-simulation/types Expand file tree Collapse file tree 1 file changed +29
-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+
9+ namespace OpenVic {
10+ template <
11+ derived_from_specialization_of<type_safe::strong_typedef> IndexType,
12+ typename ValueType,
13+ size_t _Extent = std::dynamic_extent
14+ >
15+ struct TypedSpan : public std ::span<ValueType, _Extent> {
16+ public:
17+ constexpr IndexType size () const {
18+ return IndexType (std::span<ValueType, _Extent>::size ());
19+ }
20+
21+ constexpr std::span<ValueType, _Extent>::reference operator [](const IndexType _Off) const {
22+ return std::span<ValueType, _Extent>::operator [](static_cast <std::size_t >(type_safe::get (_Off)));
23+ }
24+
25+ constexpr operator TypedSpan<IndexType, const ValueType, _Extent>() {
26+ return TypedSpan<IndexType, const ValueType, _Extent>{*this };
27+ }
28+ };
29+ }
You can’t perform that action at this time.
0 commit comments