OpenKalman
default_accessor.hpp
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 std {
23 namespace experimental {
24 
25 template <class ElementType>
27 
29  using element_type = ElementType;
30  using reference = ElementType&;
31  using data_handle_type = ElementType*;
32 
33  MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr default_accessor() noexcept = default;
34 
35  MDSPAN_TEMPLATE_REQUIRES(
36  class OtherElementType,
37  /* requires */ (
38  _MDSPAN_TRAIT(is_convertible, OtherElementType(*)[], element_type(*)[])
39  )
40  )
41  MDSPAN_INLINE_FUNCTION
43 
44  MDSPAN_INLINE_FUNCTION
45  constexpr data_handle_type
46  offset(data_handle_type p, size_t i) const noexcept {
47  return p + i;
48  }
49 
50  MDSPAN_FORCE_INLINE_FUNCTION
51  constexpr reference access(data_handle_type p, size_t i) const noexcept {
52  return p[i];
53  }
54 
55 };
56 
57 } // end namespace experimental
58 } // end namespace std
Definition: default_accessor.hpp:26