]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / experimental / utilities / meta / meta.detect / is_detected_exact.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03, c++11
11 // <experimental/type_traits>
12
13 #include <experimental/type_traits>
14 #include <string>
15
16 #include "test_macros.h"
17
18 namespace ex = std::experimental;
19
20 template <typename T>
21   using callFoo = decltype(std::declval<T&>().Foo());
22   
23 struct yesFoo {
24     int Foo() { return 0; }
25 };
26
27 struct noFoo {
28 };
29
30 struct wrongFoo {
31     std::string Foo() { return ""; }
32 };
33
34 struct convertibleFoo {
35     long Foo() { return 0; }
36 };
37
38 template <typename T, bool b>
39 void 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
44 int main () {
45     test<yesFoo, true>();
46     test<noFoo, false>();
47     test<wrongFoo, false>();
48     test<convertibleFoo, false>();
49 }