//===----------------------------------------------------------------------===// // // 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 // This test ensures that std::tuple is lazy when it comes to checking whether // the elements it is assigned from can be used to assign to the types in // the tuple. #include #include template constexpr typename std::enable_if::type BlowUp() { static_assert(Enable && sizeof...(Class) != sizeof...(Class), ""); return true; } template struct Fail { static_assert(sizeof(T) != sizeof(T), ""); using type = void; }; struct NoAssign { NoAssign() = default; NoAssign(NoAssign const&) = default; template ::type> NoAssign& operator=(T) { return *this; } }; template struct DieOnAssign { DieOnAssign() = default; template ::value>::type, class = typename Fail::type> DieOnAssign& operator=(T) { return *this; } }; void test_arity_checks() { { using T = std::tuple, int>; using P = std::pair; static_assert(!std::is_assignable::value, ""); } { using T = std::tuple >; using A = std::array; static_assert(!std::is_assignable::value, ""); } } void test_assignability_checks() { { using T1 = std::tuple >; using T2 = std::tuple; static_assert(!std::is_assignable::value, ""); } { using T1 = std::tuple >; using T2 = std::pair; static_assert(!std::is_assignable::value, ""); } } int main(int, char**) { test_arity_checks(); test_assignability_checks(); return 0; }