//===----------------------------------------------------------------------===// // // 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 // // // template // friend constexpr bool operator==(const extents& lhs, // const extents& rhs) noexcept; // // Returns: true if lhs.rank() equals rhs.rank() and // if lhs.extent(r) equals rhs.extent(r) for every rank index r of rhs, otherwise false. // #include #include #include #include // dynamic_extent #include "test_macros.h" template constexpr void test_comparison(bool equal, To dest, From src) { ASSERT_NOEXCEPT(dest == src); assert((dest == src) == equal); assert((dest != src) == !equal); } template constexpr void test_comparison_different_rank() { constexpr size_t D = std::dynamic_extent; test_comparison(false, std::extents(), std::extents(1)); test_comparison(false, std::extents(), std::extents()); test_comparison(false, std::extents(1), std::extents()); test_comparison(false, std::extents(), std::extents()); test_comparison(false, std::extents(5), std::extents(5, 5)); test_comparison(false, std::extents(), std::extents(5)); test_comparison(false, std::extents(), std::extents()); test_comparison(false, std::extents(5, 5), std::extents(5)); test_comparison(false, std::extents(5), std::extents(5)); test_comparison(false, std::extents(), std::extents()); } template constexpr void test_comparison_same_rank() { constexpr size_t D = std::dynamic_extent; test_comparison(true, std::extents(), std::extents()); test_comparison(true, std::extents(5), std::extents(5)); test_comparison(true, std::extents(), std::extents(5)); test_comparison(true, std::extents(5), std::extents()); test_comparison(true, std::extents(), std::extents< T2, 5>()); test_comparison(false, std::extents(5), std::extents(7)); test_comparison(false, std::extents(), std::extents(7)); test_comparison(false, std::extents(5), std::extents()); test_comparison(false, std::extents(), std::extents()); test_comparison(true, std::extents(5, 6, 7, 8, 9), std::extents(5, 6, 7, 8, 9)); test_comparison(true, std::extents(5, 7, 9), std::extents(6, 7)); test_comparison(true, std::extents(5, 6, 7, 8, 9), std::extents()); test_comparison( false, std::extents(5, 6, 7, 8, 9), std::extents(5, 6, 3, 8, 9)); test_comparison(false, std::extents(5, 7, 9), std::extents(6, 7)); test_comparison(false, std::extents(5, 6, 7, 8, 9), std::extents()); } template constexpr void test_comparison() { test_comparison_same_rank(); test_comparison_different_rank(); } constexpr bool test() { test_comparison(); test_comparison(); test_comparison(); test_comparison(); return true; } int main(int, char**) { test(); static_assert(test()); return 0; }