//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // // static constexpr rank_type rank() noexcept; // static constexpr rank_type rank_dynamic() noexcept; // // static constexpr size_t static_extent(rank_type i) noexcept; // // Preconditions: i < rank() is true. // // Returns: Ei. // // // constexpr index_type extent(rank_type i) const noexcept; // // Preconditions: i < rank() is true. // // Returns: Di. // #include #include #include #include // dynamic_extent #include #include "test_macros.h" template void test_static_observers(std::index_sequence, std::index_sequence) { ASSERT_NOEXCEPT(E::rank()); static_assert(E::rank() == rank); ASSERT_NOEXCEPT(E::rank_dynamic()); static_assert(E::rank_dynamic() == rank_dynamic); // Let's only test this if the call isn't a precondition violation if constexpr (rank > 0) { ASSERT_NOEXCEPT(E::static_extent(0)); ASSERT_SAME_TYPE(decltype(E::static_extent(0)), size_t); static_assert(((E::static_extent(Indices) == StaticExts) && ...)); } } template void test_static_observers() { test_static_observers( std::index_sequence(), std::make_index_sequence()); } template void test() { constexpr size_t D = std::dynamic_extent; constexpr size_t S = 5; test_static_observers, 0, 0>(); test_static_observers, 1, 0, S>(); test_static_observers, 1, 1, D>(); test_static_observers, 2, 0, S, S>(); test_static_observers, 2, 1, S, D>(); test_static_observers, 2, 1, D, S>(); test_static_observers, 2, 2, D, D>(); test_static_observers, 3, 0, S, S, S>(); test_static_observers, 3, 1, S, S, D>(); test_static_observers, 3, 1, S, D, S>(); test_static_observers, 3, 1, D, S, S>(); test_static_observers, 3, 2, S, D, D>(); test_static_observers, 3, 2, D, S, D>(); test_static_observers, 3, 2, D, D, S>(); test_static_observers, 3, 3, D, D, D>(); } int main(int, char**) { test(); test(); test(); test(); test(); return 0; }