Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
standard_layout_static_array.h704 linesDownload Raw Back to __mdspan
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_STANDARD_LAYOUT_STATIC_ARRAY_HPP45#define _LIBCUDACXX___MDSPAN_STANDARD_LAYOUT_STATIC_ARRAY_HPP46 47#ifndef __cuda_std__48#include <__config>49#endif // __cuda_std__50 51#include "../__mdspan/compressed_pair.h"52#include "../__mdspan/dynamic_extent.h"53#include "../__mdspan/macros.h"54#ifdef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS55#include "../__mdspan/no_unique_address.h"56#endif57#include "../__type_traits/enable_if.h"58#include "../__utility/integer_sequence.h"59#include "../array"60#include "../cstddef"61#include "../span"62 63#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)64#  pragma GCC system_header65#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)66#  pragma clang system_header67#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)68#  pragma system_header69#endif // no system header70 71_LIBCUDACXX_BEGIN_NAMESPACE_STD72 73#if _LIBCUDACXX_STD_VER > 1174 75namespace __detail {76 77//==============================================================================78 79struct __construct_psa_from_dynamic_exts_values_tag_t {};80_LIBCUDACXX_CPO_ACCESSIBILITY __construct_psa_from_dynamic_exts_values_tag_t __construct_psa_from_dynamic_exts_values_tag;81 82struct __construct_psa_from_all_exts_values_tag_t {};83_LIBCUDACXX_CPO_ACCESSIBILITY __construct_psa_from_all_exts_values_tag_t __construct_psa_from_all_exts_values_tag;84 85struct __construct_psa_from_all_exts_array_tag_t {};86template <size_t _Np = 0>87struct __construct_psa_from_dynamic_exts_array_tag_t {};88 89//==============================================================================90 91template <size_t _Ip, class _Tp> using __repeated_with_idxs = _Tp;92 93//==============================================================================94 95#if __MDSPAN_PRESERVE_STANDARD_LAYOUT96 97/**98 *  PSA = "partially static array"99 *100 * @tparam _Tp101 * @tparam _ValsSeq102 * @tparam __sentinal103 */104template <class _Tag, class _Tp, class _static_t, class _ValsSeq, _static_t __sentinal = static_cast<_static_t>(dynamic_extent),105          class _IdxsSeq = _CUDA_VSTD::make_index_sequence<_ValsSeq::size()>>106struct __standard_layout_psa;107 108//==============================================================================109// Static case110template <class _Tag, class _Tp, class _static_t, _static_t __value, _static_t... __values_or_sentinals,111          _static_t __sentinal, size_t _Idx, size_t... _Idxs>112struct __standard_layout_psa<113    _Tag, _Tp, _static_t, _CUDA_VSTD::integer_sequence<_static_t, __value, __values_or_sentinals...>,114    __sentinal, _CUDA_VSTD::integer_sequence<size_t, _Idx, _Idxs...>>115#ifdef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS116    : private __no_unique_address_emulation<__standard_layout_psa<117          _Tag, _Tp, _static_t, _CUDA_VSTD::integer_sequence<_static_t, __values_or_sentinals...>, __sentinal,118          _CUDA_VSTD::integer_sequence<size_t, _Idxs...>>>119#endif120{121 122  //--------------------------------------------------------------------------123 124  using __next_t =125      __standard_layout_psa<_Tag, _Tp, _static_t,126                            _CUDA_VSTD::integer_sequence<_static_t, __values_or_sentinals...>,127                            __sentinal, _CUDA_VSTD::integer_sequence<size_t, _Idxs...>>;128 129#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS130  _LIBCUDACXX_NO_UNIQUE_ADDRESS __next_t __next_;131#else132  using __base_t = __no_unique_address_emulation<__next_t>;133#endif134 135  __MDSPAN_FORCE_INLINE_FUNCTION constexpr __next_t &__next() noexcept {136#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS137    return __next_;138#else139    return this->__base_t::__ref();140#endif141  }142  __MDSPAN_FORCE_INLINE_FUNCTION constexpr __next_t const &__next() const noexcept {143#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS144    return __next_;145#else146    return this->__base_t::__ref();147#endif148  }149 150  static constexpr auto __size = sizeof...(_Idxs) + 1;151  static constexpr auto __size_dynamic = __next_t::__size_dynamic;152 153  //--------------------------------------------------------------------------154 155  __MDSPAN_INLINE_FUNCTION_DEFAULTED156  constexpr __standard_layout_psa() noexcept = default;157  __MDSPAN_INLINE_FUNCTION_DEFAULTED158  constexpr __standard_layout_psa(__standard_layout_psa const &) noexcept =159      default;160  __MDSPAN_INLINE_FUNCTION_DEFAULTED161  constexpr __standard_layout_psa(__standard_layout_psa &&) noexcept = default;162  __MDSPAN_INLINE_FUNCTION_DEFAULTED163  __MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa &164  operator=(__standard_layout_psa const &) noexcept = default;165  __MDSPAN_INLINE_FUNCTION_DEFAULTED166  __MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa &167  operator=(__standard_layout_psa &&) noexcept = default;168  __MDSPAN_INLINE_FUNCTION_DEFAULTED169  ~__standard_layout_psa() noexcept = default;170 171  //--------------------------------------------------------------------------172 173  __MDSPAN_INLINE_FUNCTION174  constexpr __standard_layout_psa(175      __construct_psa_from_all_exts_values_tag_t, _Tp const & /*__val*/,176      __repeated_with_idxs<_Idxs, _Tp> const &... __vals) noexcept177#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS178      : __next_{179#else180      : __base_t(__base_t{__next_t(181#endif182          __construct_psa_from_all_exts_values_tag, __vals...183#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS184        }185#else186        )})187#endif188  { }189 190  template <class... _Ts>191  __MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa(192      __construct_psa_from_dynamic_exts_values_tag_t,193      _Ts const &... __vals) noexcept194#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS195      : __next_{196#else197      : __base_t(__base_t{__next_t(198#endif199          __construct_psa_from_dynamic_exts_values_tag, __vals...200#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS201        }202#else203        )})204#endif205  { }206 207  template <class _Up, size_t _Np>208  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(209      array<_Up, _Np> const &__vals) noexcept210#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS211      : __next_{212#else213      : __base_t(__base_t{__next_t(214#endif215          __vals216#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS217        }218#else219        )})220#endif221  { }222 223  template <class _Up, size_t _NStatic>224  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(225      __construct_psa_from_all_exts_array_tag_t const & __tag,226      array<_Up, _NStatic> const &__vals) noexcept227#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS228      : __next_{229#else230      : __base_t(__base_t{__next_t(231#endif232          __tag, __vals233#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS234        }235#else236        )})237#endif238  { }239 240  template <class _Up, size_t _IDynamic, size_t _NDynamic>241  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(242      __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic> __tag,243      array<_Up, _NDynamic> const &__vals) noexcept244#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS245      : __next_{246#else247      : __base_t(__base_t{__next_t(248#endif249          __tag, __vals250#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS251        }252#else253        )})254#endif255  { }256 257  template <class _Up, size_t _Np>258  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(259      _CUDA_VSTD::span<_Up, _Np> const &__vals) noexcept260#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS261      : __next_{262#else263      : __base_t(__base_t{__next_t(264#endif265          __vals266#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS267        }268#else269        )})270#endif271  { }272 273  template <class _Up, size_t _NStatic>274  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(275      __construct_psa_from_all_exts_array_tag_t const & __tag,276      _CUDA_VSTD::span<_Up, _NStatic> const &__vals) noexcept277#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS278      : __next_{279#else280      : __base_t(__base_t{__next_t(281#endif282          __tag, __vals283#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS284        }285#else286        )})287#endif288  { }289 290  template <class _Up, size_t _IDynamic, size_t _NDynamic>291  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(292      __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic> __tag,293      _CUDA_VSTD::span<_Up, _NDynamic> const &__vals) noexcept294#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS295      : __next_{296#else297      : __base_t(__base_t{__next_t(298#endif299          __tag, __vals300#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS301        }302#else303        )})304#endif305  { }306 307  template <class _UTag, class _Up, class _static_U, class _UValsSeq, _static_U __u_sentinal,308            class _IdxsSeq>309  __MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa(310      __standard_layout_psa<_UTag, _Up, _static_U, _UValsSeq, __u_sentinal, _IdxsSeq> const311          &__rhs) noexcept312#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS313      : __next_{314#else315      : __base_t(__base_t{__next_t(316#endif317          __rhs.__next()318#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS319        }320#else321        )})322#endif323  { }324 325  //--------------------------------------------------------------------------326 327  // See https://godbolt.org/z/_KSDNX for a summary-by-example of why this is328  // necessary. We're using inheritance here instead of an alias template329  // because we have to deduce __values_or_sentinals in several places, and330  // alias templates don't permit that in this context.331  __MDSPAN_FORCE_INLINE_FUNCTION332  constexpr __standard_layout_psa const &__enable_psa_conversion() const333      noexcept {334    return *this;335  }336 337  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip != _Idx, int> = 0>338  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get_n() const noexcept {339    return __next().template __get_n<_Ip>();340  }341  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip == _Idx, int> = 1>342  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get_n() const noexcept {343    return __value;344  }345  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip != _Idx, int> = 0>346  __MDSPAN_FORCE_INLINE_FUNCTION constexpr void347  __set_n(_Tp const &__rhs) noexcept {348    __next().__set_value(__rhs);349  }350  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip == _Idx, int> = 1>351  __MDSPAN_FORCE_INLINE_FUNCTION constexpr void352  __set_n(_Tp const &) noexcept {353    // Don't assert here because that would break constexpr. This better354    // not change anything, though355  }356  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip == _Idx, _static_t> = __sentinal>357  __MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept {358    return __value;359  }360  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip != _Idx, _static_t> __default = __sentinal>361  __MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept {362    return __next_t::template __get_static_n<_Ip, __default>();363  }364  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get(size_t __n) const noexcept {365    return __value * (_Tp(_Idx == __n)) + __next().__get(__n);366  }367 368  //--------------------------------------------------------------------------369};370 371//==============================================================================372 373// Dynamic case, __next_t may or may not be empty374template <class _Tag, class _Tp, class _static_t, _static_t __sentinal, _static_t... __values_or_sentinals,375          size_t _Idx, size_t... _Idxs>376struct __standard_layout_psa<377    _Tag, _Tp, _static_t, _CUDA_VSTD::integer_sequence<_static_t, __sentinal, __values_or_sentinals...>,378    __sentinal, _CUDA_VSTD::integer_sequence<size_t, _Idx, _Idxs...>> {379  //--------------------------------------------------------------------------380 381  using __next_t =382      __standard_layout_psa<_Tag, _Tp, _static_t,383                            _CUDA_VSTD::integer_sequence<_static_t, __values_or_sentinals...>,384                            __sentinal, _CUDA_VSTD::integer_sequence<size_t, _Idxs...>>;385 386  using __value_pair_t = __compressed_pair<_Tp, __next_t>;387  __value_pair_t __value_pair;388  __MDSPAN_FORCE_INLINE_FUNCTION constexpr __next_t &__next() noexcept {389    return __value_pair.__second();390  }391  __MDSPAN_FORCE_INLINE_FUNCTION constexpr __next_t const &__next() const noexcept {392    return __value_pair.__second();393  }394 395  static constexpr auto __size = sizeof...(_Idxs) + 1;396  static constexpr auto __size_dynamic = 1 + __next_t::__size_dynamic;397 398  //--------------------------------------------------------------------------399 400  __MDSPAN_INLINE_FUNCTION_DEFAULTED401  constexpr __standard_layout_psa() noexcept = default;402  __MDSPAN_INLINE_FUNCTION_DEFAULTED403  constexpr __standard_layout_psa(__standard_layout_psa const &) noexcept =404      default;405  __MDSPAN_INLINE_FUNCTION_DEFAULTED406  constexpr __standard_layout_psa(__standard_layout_psa &&) noexcept = default;407  __MDSPAN_INLINE_FUNCTION_DEFAULTED408  __MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa &409  operator=(__standard_layout_psa const &) noexcept = default;410  __MDSPAN_INLINE_FUNCTION_DEFAULTED411  __MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa &412  operator=(__standard_layout_psa &&) noexcept = default;413  __MDSPAN_INLINE_FUNCTION_DEFAULTED414  ~__standard_layout_psa() noexcept = default;415 416  //--------------------------------------------------------------------------417 418  __MDSPAN_INLINE_FUNCTION419  constexpr __standard_layout_psa(420      __construct_psa_from_all_exts_values_tag_t, _Tp const &__val,421      __repeated_with_idxs<_Idxs, _Tp> const &... __vals) noexcept422      : __value_pair(__val,423                     __next_t(__construct_psa_from_all_exts_values_tag,424                              __vals...)) {}425 426  template <class... _Ts>427  __MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa(428      __construct_psa_from_dynamic_exts_values_tag_t, _Tp const &__val,429      _Ts const &... __vals) noexcept430      : __value_pair(__val,431                     __next_t(__construct_psa_from_dynamic_exts_values_tag,432                              __vals...)) {}433 434  template <class _Up, size_t _Np>435  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(436      array<_Up, _Np> const &__vals) noexcept437      : __value_pair(_CUDA_VSTD::get<_Idx>(__vals), __vals) {}438 439  template <class _Up, size_t _NStatic>440  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(441      __construct_psa_from_all_exts_array_tag_t __tag,442      array<_Up, _NStatic> const &__vals) noexcept443      : __value_pair(444            _CUDA_VSTD::get<_Idx>(__vals),445            __next_t(__tag,446                     __vals)) {}447 448  template <class _Up, size_t _IDynamic, size_t _NDynamic>449  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(450      __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>,451      array<_Up, _NDynamic> const &__vals) noexcept452      : __value_pair(453            _CUDA_VSTD::get<_IDynamic>(__vals),454            __next_t(__construct_psa_from_dynamic_exts_array_tag_t<_IDynamic + 1>{},455                     __vals)) {}456 457  template <class _Up, size_t _Np>458  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(459      _CUDA_VSTD::span<_Up, _Np> const &__vals) noexcept460      : __value_pair(__vals[_Idx], __vals) {}461 462  template <class _Up, size_t _NStatic>463  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(464      __construct_psa_from_all_exts_array_tag_t __tag,465      _CUDA_VSTD::span<_Up, _NStatic> const &__vals) noexcept466      : __value_pair(467            __vals[_Idx],468            __next_t(__tag,469                     __vals)) {}470 471  template <class _Up, size_t _IDynamic, size_t _NDynamic>472  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(473      __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>,474      _CUDA_VSTD::span<_Up, _NDynamic> const &__vals) noexcept475      : __value_pair(476            __vals[_IDynamic],477            __next_t(__construct_psa_from_dynamic_exts_array_tag_t<_IDynamic + 1>{},478                     __vals)) {}479 480  template <class _UTag, class _Up, class _static_U, class _UValsSeq, _static_U __u_sentinal,481            class _UIdxsSeq>482  __MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa(483      __standard_layout_psa<_UTag, _Up, _static_U, _UValsSeq, __u_sentinal, _UIdxsSeq> const484          &__rhs) noexcept485      : __value_pair(__rhs.template __get_n<_Idx>(), __rhs.__next()) {}486 487  //--------------------------------------------------------------------------488 489  // See comment in the previous partial specialization for why this is490  // necessary.  Or just trust me that it's messy.491  __MDSPAN_FORCE_INLINE_FUNCTION492  constexpr __standard_layout_psa const &__enable_psa_conversion() const493      noexcept {494    return *this;495  }496 497  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip != _Idx, int> = 0>498  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get_n() const noexcept {499    return __next().template __get_n<_Ip>();500  }501  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip == _Idx, int> = 1>502  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get_n() const noexcept {503    return __value_pair.__first();504  }505  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip != _Idx, int> = 0>506  __MDSPAN_FORCE_INLINE_FUNCTION constexpr void507  __set_n(_Tp const &__rhs) noexcept {508    __next().__set_value(__rhs);509  }510  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip == _Idx, int> = 1>511  __MDSPAN_FORCE_INLINE_FUNCTION constexpr void512  __set_n(_Tp const &__rhs) noexcept {513    __value_pair.__first() = __rhs;514  }515  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip == _Idx, _static_t> __default = __sentinal>516  __MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept {517    return __default;518  }519  template <size_t _Ip, _CUDA_VSTD::enable_if_t<_Ip != _Idx, _static_t> __default = __sentinal>520  __MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept {521    return __next_t::template __get_static_n<_Ip, __default>();522  }523  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get(size_t __n) const noexcept {524    return __value_pair.__first() * (_Tp(_Idx == __n)) + __next().__get(__n);525  }526 527  //--------------------------------------------------------------------------528};529 530// empty/terminal case531template <class _Tag, class _Tp, class _static_t, _static_t __sentinal>532struct __standard_layout_psa<_Tag, _Tp, _static_t, _CUDA_VSTD::integer_sequence<_static_t>, __sentinal,533                             _CUDA_VSTD::integer_sequence<size_t>> {534  //--------------------------------------------------------------------------535 536  static constexpr auto __size = 0;537  static constexpr auto __size_dynamic = 0;538 539  //--------------------------------------------------------------------------540 541  __MDSPAN_INLINE_FUNCTION_DEFAULTED542  constexpr __standard_layout_psa() noexcept = default;543  __MDSPAN_INLINE_FUNCTION_DEFAULTED544  constexpr __standard_layout_psa(__standard_layout_psa const &) noexcept = default;545  __MDSPAN_INLINE_FUNCTION_DEFAULTED546  constexpr __standard_layout_psa(__standard_layout_psa &&) noexcept = default;547  __MDSPAN_INLINE_FUNCTION_DEFAULTED548  __MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa &549  operator=(__standard_layout_psa const &) noexcept = default;550  __MDSPAN_INLINE_FUNCTION_DEFAULTED551  __MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa &552  operator=(__standard_layout_psa &&) noexcept = default;553  __MDSPAN_INLINE_FUNCTION_DEFAULTED554  ~__standard_layout_psa() noexcept = default;555 556  __MDSPAN_INLINE_FUNCTION557  constexpr __standard_layout_psa(558      __construct_psa_from_all_exts_values_tag_t) noexcept {}559 560  template <class... _Ts>561  __MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa(562      __construct_psa_from_dynamic_exts_values_tag_t) noexcept {}563 564  template <class _Up, size_t _Np>565  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(566      array<_Up, _Np> const &) noexcept {}567 568  template <class _Up, size_t _NStatic>569  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(570      __construct_psa_from_all_exts_array_tag_t,571      array<_Up, _NStatic> const &) noexcept {}572 573  template <class _Up, size_t _IDynamic, size_t _NDynamic>574  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(575      __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>,576      array<_Up, _NDynamic> const &) noexcept {}577 578  template <class _Up, size_t _Np>579  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(580      _CUDA_VSTD::span<_Up, _Np> const &) noexcept {}581 582  template <class _Up, size_t _NStatic>583  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(584      __construct_psa_from_all_exts_array_tag_t,585      _CUDA_VSTD::span<_Up, _NStatic> const &) noexcept {}586 587  template <class _Up, size_t _IDynamic, size_t _NDynamic>588  __MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa(589      __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>,590      _CUDA_VSTD::span<_Up, _NDynamic> const &) noexcept {}591 592  template <class _UTag, class _Up, class _static_U, class _UValsSeq, _static_U __u_sentinal,593            class _UIdxsSeq>594  __MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa(595      __standard_layout_psa<_UTag, _Up, _static_U, _UValsSeq, __u_sentinal, _UIdxsSeq> const&) noexcept {}596 597  // See comment in the previous partial specialization for why this is598  // necessary.  Or just trust me that it's messy.599  __MDSPAN_FORCE_INLINE_FUNCTION600  constexpr __standard_layout_psa const &__enable_psa_conversion() const601      noexcept {602    return *this;603  }604 605  __MDSPAN_FORCE_INLINE_FUNCTION constexpr _Tp __get(size_t /*n*/) const noexcept {606    return 0;607  }608};609 610// Same thing, but with a disambiguator so that same-base issues doesn't cause611// a loss of standard-layout-ness.612template <class _Tag, class T, class _static_t, _static_t... __values_or_sentinals>613struct __partially_static_sizes_tagged614    : __standard_layout_psa<615          _Tag, T, _static_t,616          _CUDA_VSTD::integer_sequence<_static_t, __values_or_sentinals...>> {617  using __tag_t = _Tag;618  using __psa_impl_t = __standard_layout_psa<619      _Tag, T, _static_t, _CUDA_VSTD::integer_sequence<_static_t, __values_or_sentinals...>>;620#if defined(_LIBCUDACXX_COMPILER_NVRTC) \621 || defined(_LIBCUDACXX_CUDACC_BELOW_11_3)622  template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __psa_impl_t, _Args...), int> = 0>623  __MDSPAN_FORCE_INLINE_FUNCTION constexpr624  __partially_static_sizes_tagged(_Args&&... __args) noexcept(noexcept(__psa_impl_t(_CUDA_VSTD::declval<_Args>()...)))625      : __psa_impl_t(_CUDA_VSTD::forward<_Args>(__args)...)626  {}627#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv628  using __psa_impl_t::__psa_impl_t;629#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3630#ifdef __MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND631  __MDSPAN_INLINE_FUNCTION632#endif633  constexpr __partially_static_sizes_tagged() noexcept634#ifdef __MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND635    : __psa_impl_t() { }636#else637    = default;638#endif639  __MDSPAN_INLINE_FUNCTION_DEFAULTED640  constexpr __partially_static_sizes_tagged(641      __partially_static_sizes_tagged const &) noexcept = default;642  __MDSPAN_INLINE_FUNCTION_DEFAULTED643  constexpr __partially_static_sizes_tagged(644      __partially_static_sizes_tagged &&) noexcept = default;645  __MDSPAN_INLINE_FUNCTION_DEFAULTED646  __MDSPAN_CONSTEXPR_14_DEFAULTED __partially_static_sizes_tagged &647  operator=(__partially_static_sizes_tagged const &) noexcept = default;648  __MDSPAN_INLINE_FUNCTION_DEFAULTED649  __MDSPAN_CONSTEXPR_14_DEFAULTED __partially_static_sizes_tagged &650  operator=(__partially_static_sizes_tagged &&) noexcept = default;651  __MDSPAN_INLINE_FUNCTION_DEFAULTED652  ~__partially_static_sizes_tagged() noexcept = default;653 654  template <class _UTag>655  __MDSPAN_FORCE_INLINE_FUNCTION constexpr explicit __partially_static_sizes_tagged(656    __partially_static_sizes_tagged<_UTag, T, _static_t, __values_or_sentinals...> const& __vals657  ) noexcept : __psa_impl_t(__vals.__enable_psa_conversion()) { }658};659 660struct __no_tag {};661template <class T, class _static_t, _static_t... __values_or_sentinals>662struct __partially_static_sizes663    : __partially_static_sizes_tagged<__no_tag, T, _static_t, __values_or_sentinals...> {664private:665  using __base_t =666      __partially_static_sizes_tagged<__no_tag, T, _static_t, __values_or_sentinals...>;667  template <class _UTag>668  __MDSPAN_FORCE_INLINE_FUNCTION constexpr __partially_static_sizes(669    __partially_static_sizes_tagged<_UTag, T, _static_t, __values_or_sentinals...>&& __vals670  ) noexcept : __base_t(_CUDA_VSTD::move(__vals)) { }671public:672#if defined(_LIBCUDACXX_COMPILER_NVRTC) \673 || defined(_LIBCUDACXX_CUDACC_BELOW_11_3)674  template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base_t, _Args...), int> = 0>675  __MDSPAN_FORCE_INLINE_FUNCTION constexpr676  __partially_static_sizes(_Args&&... __args) noexcept(noexcept(__base_t(_CUDA_VSTD::declval<_Args>()...)))677      : __base_t(_CUDA_VSTD::forward<_Args>(__args)...)678  {}679#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv680  using __base_t::__base_t;681#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3682 683#ifdef __MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND684  __MDSPAN_INLINE_FUNCTION685  constexpr __partially_static_sizes() noexcept : __base_t() { }686#endif687  template <class _UTag>688  __MDSPAN_FORCE_INLINE_FUNCTION constexpr __partially_static_sizes_tagged<689      _UTag, T, _static_t, __values_or_sentinals...>690  __with_tag() const noexcept {691    return __partially_static_sizes_tagged<_UTag, T, _static_t, __values_or_sentinals...>(*this);692  }693};694 695#endif // __MDSPAN_PRESERVE_STATIC_LAYOUT696 697} // end namespace __detail698 699#endif // _LIBCUDACXX_STD_VER > 11700 701_LIBCUDACXX_END_NAMESPACE_STD702 703#endif // _LIBCUDACXX___MDSPAN_STANDARD_LAYOUT_STATIC_ARRAY_HPP704 
codekingpro/portable-devtools · Team Ai