//===----------------------------------------------------------------------===// // // 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 // template PairLike> // requires pair-like-convertible-from // constexpr operator PairLike() const; #include #include #include #include #include #include "test_macros.h" static_assert(std::convertible_to, std::pair>); static_assert(std::convertible_to, std::tuple>); static_assert(!std::convertible_to, std::pair>); static_assert(!std::convertible_to, std::pair>); static_assert(!std::convertible_to, std::pair>); static_assert(!std::convertible_to, std::array>); constexpr bool test() { // Check to std::pair { int data[] = {1, 2, 3, 4, 5}; const std::ranges::subrange a(data); { std::pair p(a); assert(p.first == data + 0); assert(p.second == data + 5); } { std::pair p{a}; assert(p.first == data + 0); assert(p.second == data + 5); } { std::pair p = a; assert(p.first == data + 0); assert(p.second == data + 5); } } // Check to std::tuple { int data[] = {1, 2, 3, 4, 5}; const std::ranges::subrange a(data); { std::tuple p(a); assert(std::get<0>(p) == data + 0); assert(std::get<1>(p) == data + 5); } { std::tuple p{a}; assert(std::get<0>(p) == data + 0); assert(std::get<1>(p) == data + 5); } { std::tuple p = a; assert(std::get<0>(p) == data + 0); assert(std::get<1>(p) == data + 5); } } return true; } int main(int, char**) { test(); static_assert(test()); return 0; }