codekingpro/portable-devtools
114k
1/*2//@HEADER3// ************************************************************************4//5// Kokkos v. 2.06// Copyright (2019) Sandia Corporation7//8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,9// the U.S. Government retains certain rights in this software.10//11// Redistribution and use in source and binary forms, with or without12// modification, are permitted provided that the following conditions are13// met:14//15// 1. Redistributions of source code must retain the above copyright16// notice, this list of conditions and the following disclaimer.17//18// 2. Redistributions in binary form must reproduce the above copyright19// notice, this list of conditions and the following disclaimer in the20// documentation and/or other materials provided with the distribution.21//22// 3. Neither the name of the Corporation nor the names of the23// contributors may be used to endorse or promote products derived from24// this software without specific prior written permission.25//26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.37//38// Questions? Contact Christian R. Trott (crtrott@sandia.gov)39//40// ************************************************************************41//@HEADER42*/43 44#ifndef _LIBCUDACXX___MDSPAN_DEFAULT_ACCESSOR_HPP45#define _LIBCUDACXX___MDSPAN_DEFAULT_ACCESSOR_HPP46 47#ifndef __cuda_std__48#include <__config>49#endif // __cuda_std__50 51#include "../__mdspan/macros.h"52#include "../__type_traits/is_convertible.h"53#include "../cstddef"54 55#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)56# pragma GCC system_header57#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)58# pragma clang system_header59#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)60# pragma system_header61#endif // no system header62 63_LIBCUDACXX_BEGIN_NAMESPACE_STD64 65#if _LIBCUDACXX_STD_VER > 1166 67template <class _ElementType>68struct default_accessor {69 70 using offset_policy = default_accessor;71 using element_type = _ElementType;72 using reference = _ElementType&;73 using data_handle_type = _ElementType*;74 75 __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr default_accessor() noexcept = default;76 77 __MDSPAN_TEMPLATE_REQUIRES(78 class _OtherElementType,79 /* requires */ (80 _LIBCUDACXX_TRAIT(is_convertible, _OtherElementType(*)[], element_type(*)[])81 )82 )83 __MDSPAN_INLINE_FUNCTION84 constexpr default_accessor(default_accessor<_OtherElementType>) noexcept {}85 86 __MDSPAN_INLINE_FUNCTION87 constexpr data_handle_type88 offset(data_handle_type __p, size_t __i) const noexcept {89 return __p + __i;90 }91 92 __MDSPAN_FORCE_INLINE_FUNCTION93 constexpr reference access(data_handle_type __p, size_t __i) const noexcept {94 return __p[__i];95 }96 97};98 99#endif // _LIBCUDACXX_STD_VER > 11100 101_LIBCUDACXX_END_NAMESPACE_STD102 103#endif // _LIBCUDACXX___MDSPAN_DEFAULT_ACCESSOR_HPP104 