Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:55

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //                        Kokkos v. 4.0
0009 //       Copyright (2022) National Technology & Engineering
0010 //               Solutions of Sandia, LLC (NTESS).
0011 //
0012 // Under the terms of Contract DE-NA0003525 with NTESS,
0013 // the U.S. Government retains certain rights in this software.
0014 //
0015 //===---------------------------------------------------------------------===//
0016 
0017 #ifndef _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H
0018 #define _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H
0019 
0020 #include <__config>
0021 #include <__cstddef/size_t.h>
0022 #include <__type_traits/is_abstract.h>
0023 #include <__type_traits/is_array.h>
0024 #include <__type_traits/is_convertible.h>
0025 #include <__type_traits/remove_const.h>
0026 
0027 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 #  pragma GCC system_header
0029 #endif
0030 
0031 _LIBCPP_PUSH_MACROS
0032 #include <__undef_macros>
0033 
0034 _LIBCPP_BEGIN_NAMESPACE_STD
0035 
0036 #if _LIBCPP_STD_VER >= 23
0037 
0038 template <class _ElementType>
0039 struct default_accessor {
0040   static_assert(!is_array_v<_ElementType>, "default_accessor: template argument may not be an array type");
0041   static_assert(!is_abstract_v<_ElementType>, "default_accessor: template argument may not be an abstract class");
0042 
0043   using offset_policy    = default_accessor;
0044   using element_type     = _ElementType;
0045   using reference        = _ElementType&;
0046   using data_handle_type = _ElementType*;
0047 
0048   _LIBCPP_HIDE_FROM_ABI constexpr default_accessor() noexcept = default;
0049   template <class _OtherElementType>
0050     requires(is_convertible_v<_OtherElementType (*)[], element_type (*)[]>)
0051   _LIBCPP_HIDE_FROM_ABI constexpr default_accessor(default_accessor<_OtherElementType>) noexcept {}
0052 
0053   _LIBCPP_HIDE_FROM_ABI constexpr reference access(data_handle_type __p, size_t __i) const noexcept { return __p[__i]; }
0054   _LIBCPP_HIDE_FROM_ABI constexpr data_handle_type offset(data_handle_type __p, size_t __i) const noexcept {
0055     return __p + __i;
0056   }
0057 };
0058 
0059 #endif // _LIBCPP_STD_VER >= 23
0060 
0061 _LIBCPP_END_NAMESPACE_STD
0062 
0063 _LIBCPP_POP_MACROS
0064 
0065 #endif // _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H