brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · de1d223 Raw
53 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 38 39template <typename T, bool b>40void test() {41    static_assert( b == ex::is_detected_convertible  <int, callFoo, T>::value, "" );42    static_assert( b == ex::is_detected_convertible_v<int, callFoo, T>, "" );43}44 45int main(int, char**) {46    test<yesFoo, true>();47    test<noFoo, false>();48    test<wrongFoo, false>();49    test<convertibleFoo, true>();50 51  return 0;52}53