]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
Vendor import of libc++ trunk r291012:
[FreeBSD/FreeBSD.git] / test / std / experimental / utilities / meta / meta.detect / detected_or.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 hasFoo = typename T::Foo;
22
23 struct yesFoo {
24     using Foo = int;
25 };
26
27 struct noFoo {
28 };
29
30
31 template <typename T, typename Res>
32 void test() {
33     static_assert( std::is_same<Res, typename ex::detected_or  <double, hasFoo, T>::type>::value, "" );
34     static_assert( std::is_same<Res, typename ex::detected_or_t<double, hasFoo, T>      >::value, "" );
35 }
36
37 int main () {
38     test<yesFoo, int>();
39     test<noFoo, double>();
40 }