1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
13 // template <class ...Types> class variant;
15 // Make sure that the implicitly-generated CTAD works.
17 // We make sure that it is not ill-formed, however we still produce a warning for
18 // this one because explicit construction from a variant using CTAD is ambiguous
19 // (in the sense that the programmer intent is not clear).
20 // ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ctad-maybe-unsupported
24 #include "test_macros.h"
26 int main(int, char**) {
27 // This is the motivating example from P0739R0
29 std::variant
<int, double> v1(3);
31 ASSERT_SAME_TYPE(decltype(v2
), std::variant
<int, double>);
35 std::variant
<int, double> v1(3);
36 std::variant v2
= std::variant(v1
); // Technically valid, but intent is ambiguous!
37 ASSERT_SAME_TYPE(decltype(v2
), std::variant
<int, double>);