1//===----------------------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14
10
11// <variant>
12
13// template <class ...Types> class variant;
14
15// template <class T>
16// variant& operator=(T&&) noexcept(see below);
17
18#include <variant>
19#include <string>
20#include <memory>
21
22#include "variant_test_helpers.h"
23
24int main(int, char**)
25{
26 static_assert(!std::is_assignable<std::variant<int, int>, int>::value, "");
27 static_assert(!std::is_assignable<std::variant<long, long long>, int>::value, "");
28 static_assert(!std::is_assignable<std::variant<char>, int>::value, "");
29
30 static_assert(!std::is_assignable<std::variant<std::string, float>, int>::value, "");
31 static_assert(!std::is_assignable<std::variant<std::string, double>, int>::value, "");
32 static_assert(!std::is_assignable<std::variant<std::string, bool>, int>::value, "");
33
34 static_assert(!std::is_assignable<std::variant<int, bool>, decltype("meow")>::value, "");
35 static_assert(!std::is_assignable<std::variant<int, const bool>, decltype("meow")>::value, "");
36
37 static_assert(std::is_assignable<std::variant<bool>, std::true_type>::value, "");
38 static_assert(!std::is_assignable<std::variant<bool>, std::unique_ptr<char> >::value, "");
39 static_assert(!std::is_assignable<std::variant<bool>, decltype(nullptr)>::value, "");
40
41 return 0;
42}
43

source code of libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp