Home | History | Annotate | Download | only in variant.get
      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 T, class... Types>
     16 // constexpr bool holds_alternative(const variant<Types...>& v) noexcept;
     17 
     18 #include "test_macros.h"
     19 #include <variant>
     20 
     21 int main() {
     22   {
     23     using V = std::variant<int>;
     24     constexpr V v;
     25     static_assert(std::holds_alternative<int>(v), "");
     26   }
     27   {
     28     using V = std::variant<int, long>;
     29     constexpr V v;
     30     static_assert(std::holds_alternative<int>(v), "");
     31     static_assert(!std::holds_alternative<long>(v), "");
     32   }
     33   { // noexcept test
     34     using V = std::variant<int>;
     35     const V v;
     36     ASSERT_NOEXCEPT(std::holds_alternative<int>(v));
     37   }
     38 }
     39