5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_CONSTANT_SEQUENCE_ACCESSOR_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_CONSTANT_SEQUENCE_ACCESSOR_HPP_
11#include "arene/base/stdlib_choice/cstddef.hpp"
12#include "arene/base/stdlib_choice/enable_if.hpp"
13#include "arene/base/stdlib_choice/is_abstract.hpp"
14#include "arene/base/stdlib_choice/is_convertible.hpp"
15#include "arene/base/stdlib_choice/is_object.hpp"
19namespace constant_sequence_accessor_detail {
24template <
typename Sequence,
typename = constra
ints<>>
25extern constexpr bool has_values_member_v =
false;
30template <
typename Sequence>
31extern constexpr bool has_values_member_v<Sequence,
constraints<
decltype(Sequence::values())>> =
true;
39template <
typename Sequence,
typename = constra
ints<>>
40extern constexpr array<
typename Sequence::value_type, Sequence::size()> sequence_values_v{Sequence::values()};
47 template <
typename SequenceElementType, SequenceElementType... Values>
48 class SequenceTemplate,
49 typename SequenceElementType,
50 SequenceElementType... Values>
51extern constexpr array<SequenceElementType, sizeof...(Values)> sequence_values_v<
52 SequenceTemplate<SequenceElementType, Values...>,
55 std::enable_if_t<!has_values_member_v<SequenceTemplate<SequenceElementType, Values...>>>>>{Values...};
72template <
typename Sequence,
typename ElementType =
typename Sequence::value_type>
79 "Raw sequence value_type must be convertible to ElementType"
100 return static_cast<ElementType
>(constant_sequence_accessor_detail::sequence_values_v<Sequence>[data_handle + index]
108 return data_handle + index;
Accessor policy for mdspan which returns values from a compile time sequence.
Definition constant_sequence_accessor.hpp:73
ElementType reference
The type of a "reference" to the element — this is the same as the element type, so no backing data i...
Definition constant_sequence_accessor.hpp:88
static constexpr auto offset(data_handle_type data_handle, std::size_t index) noexcept -> data_handle_type
Return the data handle value to use with the offset policy for the given data handle and index.
Definition constant_sequence_accessor.hpp:107
std::size_t data_handle_type
The type of the data handle — this is the index into the sequence from which to start the accesses.
Definition constant_sequence_accessor.hpp:85
constant_sequence_accessor offset_policy
The type of the accessor policy for accessing data with an offset — this is constant_sequence_accesso...
Definition constant_sequence_accessor.hpp:91
ElementType element_type
The type of the element.
Definition constant_sequence_accessor.hpp:83
static constexpr auto access(data_handle_type data_handle, std::size_t index) noexcept -> reference
Return the value for the given data handle and index. The index is ignored as the value is always con...
Definition constant_sequence_accessor.hpp:98
static constexpr value_type value
Definition integral_constant.hpp:34
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Definition accumulate.hpp:37
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41