brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 38cf34a Raw
47 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++14, c++17, c++20, c++2310 11// <variant>12 13// class variant;14// template<class Self, class Visitor>15//   constexpr decltype(auto) visit(this Self&&, Visitor&&); // since C++2616// template<class R, class Self, class Visitor>17//   constexpr R visit(this Self&&, Visitor&&);              // since C++2618 19#include <variant>20 21#include "test_macros.h"22 23struct Incomplete;24template <class T>25struct Holder {26  T t;27};28 29constexpr bool test(bool do_it) {30  if (do_it) {31    std::variant<Holder<Incomplete>*, int> v = nullptr;32 33    v.visit([](auto) {});34    v.visit([](auto) -> Holder<Incomplete>* { return nullptr; });35    v.visit<void>([](auto) {});36    v.visit<void*>([](auto) -> Holder<Incomplete>* { return nullptr; });37  }38  return true;39}40 41int main(int, char**) {42  test(true);43  static_assert(test(true));44 45  return 0;46}47