Path: blob/main/contrib/llvm-project/libcxx/include/__mdspan/default_accessor.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7// Kokkos v. 4.08// Copyright (2022) National Technology & Engineering9// Solutions of Sandia, LLC (NTESS).10//11// Under the terms of Contract DE-NA0003525 with NTESS,12// the U.S. Government retains certain rights in this software.13//14//===---------------------------------------------------------------------===//1516#ifndef _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H17#define _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H1819#include <__config>20#include <__type_traits/is_abstract.h>21#include <__type_traits/is_array.h>22#include <__type_traits/is_convertible.h>23#include <__type_traits/remove_const.h>24#include <cinttypes>25#include <cstddef>2627#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28# pragma GCC system_header29#endif3031_LIBCPP_PUSH_MACROS32#include <__undef_macros>3334_LIBCPP_BEGIN_NAMESPACE_STD3536#if _LIBCPP_STD_VER >= 233738template <class _ElementType>39struct default_accessor {40static_assert(!is_array_v<_ElementType>, "default_accessor: template argument may not be an array type");41static_assert(!is_abstract_v<_ElementType>, "default_accessor: template argument may not be an abstract class");4243using offset_policy = default_accessor;44using element_type = _ElementType;45using reference = _ElementType&;46using data_handle_type = _ElementType*;4748_LIBCPP_HIDE_FROM_ABI constexpr default_accessor() noexcept = default;49template <class _OtherElementType>50requires(is_convertible_v<_OtherElementType (*)[], element_type (*)[]>)51_LIBCPP_HIDE_FROM_ABI constexpr default_accessor(default_accessor<_OtherElementType>) noexcept {}5253_LIBCPP_HIDE_FROM_ABI constexpr reference access(data_handle_type __p, size_t __i) const noexcept { return __p[__i]; }54_LIBCPP_HIDE_FROM_ABI constexpr data_handle_type offset(data_handle_type __p, size_t __i) const noexcept {55return __p + __i;56}57};5859#endif // _LIBCPP_STD_VER >= 236061_LIBCPP_END_NAMESPACE_STD6263_LIBCPP_POP_MACROS6465#endif // _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H666768