• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
FooyesFoo24     int Foo() { return 0; }
25 };
26 
27 struct noFoo {
28 };
29 
30 struct wrongFoo {
FoowrongFoo31     std::string Foo() { return ""; }
32 };
33 
34 struct convertibleFoo {
FooconvertibleFoo35     long Foo() { return 0; }
36 };
37 
38 
39 template <typename T, bool b>
test()40 void 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 
main()45 int main () {
46     test<yesFoo, true>();
47     test<noFoo, false>();
48     test<wrongFoo, false>();
49     test<convertibleFoo, true>();
50 }
51