1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 
11 // UNSUPPORTED: c++98, c++03, c++11, c++14
12 
13 // <variant>
14 
15 // template <class ...Types> class variant;
16 
17 // constexpr bool valueless_by_exception() const noexcept;
18 
19 #include <cassert>
20 #include <string>
21 #include <type_traits>
22 #include <variant>
23 
24 #include "archetypes.hpp"
25 #include "test_macros.h"
26 #include "variant_test_helpers.hpp"
27 
28 int main() {
29   {
30     using V = std::variant<int, ConstexprTestTypes::NoCtors>;
31     constexpr V v;
32     static_assert(!v.valueless_by_exception(), "");
33   }
34   {
35     using V = std::variant<int, long, std::string>;
36     const V v("abc");
37     assert(!v.valueless_by_exception());
38   }
39 #ifndef TEST_HAS_NO_EXCEPTIONS
40   {
41     using V = std::variant<int, MakeEmptyT>;
42     V v;
43     assert(!v.valueless_by_exception());
44     makeEmpty(v);
45     assert(v.valueless_by_exception());
46   }
47 #endif
48 }
49