Files
TheRock/math-libs/libhipcxx/.upstream-tests/test/std/containers/sequences/array/indexing.pass.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

80 lines
1.9 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// under the Apache License v2.0 with LLVM Exceptions.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
// <cuda/std/array>
// reference operator[](size_type); // constexpr in C++17
// Libc++ marks it as noexcept
#include <cuda/std/array>
#include <cuda/std/cassert>
#include "test_macros.h"
__host__ __device__ constexpr bool tests()
{
{
typedef double T;
typedef cuda::std::array<T, 3> C;
C c = {1, 2, 3.5};
static_assert(noexcept(c[0]));
static_assert(cuda::std::is_same_v<C::reference, decltype(c[0])>);
C::reference r1 = c[0];
assert(r1 == 1);
r1 = 5.5;
assert(c.front() == 5.5);
C::reference r2 = c[2];
assert(r2 == 3.5);
r2 = 7.5;
assert(c.back() == 7.5);
}
// Test operator[] "works" on zero sized arrays
{
{
typedef double T;
typedef cuda::std::array<T, 0> C;
C c = {};
static_assert(noexcept(c[0]));
static_assert(cuda::std::is_same_v<C::reference, decltype(c[0])>);
if (c.size() > (0))
{ // always false
#if !TEST_COMPILER(MSVC)
C::reference r = c[0];
unused(r);
#endif // !TEST_COMPILER(MSVC)
}
}
{
typedef double T;
typedef cuda::std::array<const T, 0> C;
C c = {};
static_assert(noexcept(c[0]));
static_assert(cuda::std::is_same_v<C::reference, decltype(c[0])>);
if (c.size() > (0))
{ // always false
#if !TEST_COMPILER(MSVC)
C::reference r = c[0];
unused(r);
#endif // !TEST_COMPILER(MSVC)
}
}
}
return true;
}
int main(int, char**)
{
tests();
static_assert(tests(), "");
return 0;
}