brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 9fd3822 Raw
39 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <variant>12 13// template <class T, class... Types>14// constexpr bool holds_alternative(const variant<Types...>& v) noexcept;15 16#include "test_macros.h"17#include <variant>18 19int main(int, char**) {20  {21    using V = std::variant<int>;22    constexpr V v;23    static_assert(std::holds_alternative<int>(v), "");24  }25  {26    using V = std::variant<int, long>;27    constexpr V v;28    static_assert(std::holds_alternative<int>(v), "");29    static_assert(!std::holds_alternative<long>(v), "");30  }31  { // noexcept test32    using V = std::variant<int>;33    const V v;34    ASSERT_NOEXCEPT(std::holds_alternative<int>(v));35  }36 37  return 0;38}39