tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
default_accessor.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_MDSPAN_DEFAULT_ACCESSOR_HPP
4#define TETL_MDSPAN_DEFAULT_ACCESSOR_HPP
5
8
9namespace etl {
10
11template <typename ElementType>
14 using element_type = ElementType;
15 using reference = ElementType&;
16 using data_handle_type = ElementType*;
17
18 constexpr default_accessor() noexcept = default;
19
20 template <typename OtherElementType>
21 requires is_convertible_v<OtherElementType (*)[], element_type (*)[]>
22 constexpr default_accessor(default_accessor<OtherElementType> /*unused*/) noexcept
23 {
24 }
25
26 [[nodiscard]] constexpr auto access(data_handle_type p, size_t i) const noexcept -> reference { return p[i]; }
27
28 [[nodiscard]] constexpr auto offset(data_handle_type p, size_t i) const noexcept -> data_handle_type
29 {
30 return p + i;
31 }
32};
33
34} // namespace etl
35
36#endif // TETL_MDSPAN_DEFAULT_ACCESSOR_HPP
Definition adjacent_find.hpp:8
constexpr bool is_convertible_v
Definition is_convertible.hpp:46
ElementType & reference
Definition default_accessor.hpp:15
constexpr auto access(data_handle_type p, size_t i) const noexcept -> reference
Definition default_accessor.hpp:26
constexpr default_accessor() noexcept=default
ElementType element_type
Definition default_accessor.hpp:14
constexpr auto offset(data_handle_type p, size_t i) const noexcept -> data_handle_type
Definition default_accessor.hpp:28
default_accessor offset_policy
Definition default_accessor.hpp:13
ElementType * data_handle_type
Definition default_accessor.hpp:16