• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
main()29 int main() {
30   {
31     using V = std::variant<int, long>;
32     constexpr V v;
33     static_assert(!v.valueless_by_exception(), "");
34   }
35   {
36     using V = std::variant<int, long>;
37     V v;
38     assert(!v.valueless_by_exception());
39   }
40   {
41     using V = std::variant<int, long, std::string>;
42     const V v("abc");
43     assert(!v.valueless_by_exception());
44   }
45 #ifndef TEST_HAS_NO_EXCEPTIONS
46   {
47     using V = std::variant<int, MakeEmptyT>;
48     V v;
49     assert(!v.valueless_by_exception());
50     makeEmpty(v);
51     assert(v.valueless_by_exception());
52   }
53 #endif
54 }
55