Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/openvic-simulation/types/TypedSpan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@

namespace OpenVic {
template<
derived_from_specialization_of<type_safe::strong_typedef> IndexType,
is_strongly_typed IndexType,
typename ValueType,
size_t _Extent = std::dynamic_extent
>
struct TypedSpan : public forwardable_span<ValueType, _Extent> {
public:
using forwardable_span<ValueType, _Extent>::forwardable_span;

constexpr IndexType size() const {
[[nodiscard]] constexpr IndexType size() const {
return IndexType(forwardable_span<ValueType, _Extent>::size());
}

constexpr forwardable_span<ValueType, _Extent>::reference operator[](const IndexType _Off) const {
assert(_Off < size());
return forwardable_span<ValueType, _Extent>::operator[](static_cast<std::size_t>(type_safe::get(_Off)));
[[nodiscard]] constexpr forwardable_span<ValueType, _Extent>::reference operator[](const IndexType index) const {
assert(index < size());
return forwardable_span<ValueType, _Extent>::operator[](static_cast<std::size_t>(type_safe::get(index)));
}

constexpr operator TypedSpan<IndexType, const ValueType, _Extent>() {
[[nodiscard]] constexpr operator TypedSpan<IndexType, const ValueType, _Extent>() const {
return TypedSpan<IndexType, const ValueType, _Extent>{*this};
}
};
Expand Down
Loading