Debian Codegraph @

packages/kokkos/tpls/mdspan/include/experimental/__p0009_bits/default_accessor.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 #pragma once
17
18 #include "macros.hpp"
19
20 #include <cstddef> // size_t
21
22 namespace MDSPAN_IMPL_STANDARD_NAMESPACE {
23
24 template <class ElementType>
25 struct default_accessor {
26
27 using offset_policy = default_accessor;
28 using element_type = ElementType;
29 using reference = ElementType&;
30 using data_handle_type = ElementType*;
31
32 MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr default_accessor() noexcept = default;
33
34 MDSPAN_TEMPLATE_REQUIRES(
35 class OtherElementType,
36 /* requires */ (
37 _MDSPAN_TRAIT(std::is_convertible, OtherElementType(*)[], element_type(*)[])
38 )
39 )
40 MDSPAN_INLINE_FUNCTION
41 constexpr default_accessor(default_accessor<OtherElementType>) noexcept {}
42
43 MDSPAN_INLINE_FUNCTION
44 constexpr data_handle_type
45 offset(data_handle_type p, size_t i) const noexcept {
46 return p + i;
47 }
48
49 MDSPAN_FORCE_INLINE_FUNCTION
50 constexpr reference access(data_handle_type p, size_t i) const noexcept {
51 return p[i];
52 }
53
54 };
55
56 } // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE