brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 2161c11 Raw
52 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++1110// <experimental/type_traits>11 12#include <experimental/type_traits>13#include <string>14#include <utility>15 16#include "test_macros.h"17 18namespace ex = std::experimental;19 20template <typename T>21  using callFoo = decltype(std::declval<T&>().Foo());22 23struct yesFoo {24    int Foo() { return 0; }25};26 27struct noFoo {28};29 30struct wrongFoo {31    std::string Foo() { return ""; }32};33 34struct convertibleFoo {35    long Foo() { return 0; }36};37 38template <typename T, bool b>39void test() {40    static_assert( b == ex::is_detected_exact  <int, callFoo, T>::value, "" );41    static_assert( b == ex::is_detected_exact_v<int, callFoo, T>, "" );42}43 44int main(int, char**) {45    test<yesFoo, true>();46    test<noFoo, false>();47    test<wrongFoo, false>();48    test<convertibleFoo, false>();49 50  return 0;51}52