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 #include <functional>
12 #include <string>
13
14 template <class T>
15 struct is_transparent
16 {
17 private:
18 struct two {char lx; char lxx;};
19 template <class U> static two test(...);
20 template <class U> static char test(typename U::is_transparent* = 0);
21 public:
22 static const bool value = sizeof(test<T>(0)) == 1;
23 };
24
25
main()26 int main ()
27 {
28 static_assert ( !is_transparent<std::less<int>>::value, "" );
29 static_assert ( !is_transparent<std::less<std::string>>::value, "" );
30 static_assert ( is_transparent<std::less<void>>::value, "" );
31 static_assert ( is_transparent<std::less<>>::value, "" );
32
33 static_assert ( !is_transparent<std::less_equal<int>>::value, "" );
34 static_assert ( !is_transparent<std::less_equal<std::string>>::value, "" );
35 static_assert ( is_transparent<std::less_equal<void>>::value, "" );
36 static_assert ( is_transparent<std::less_equal<>>::value, "" );
37
38 static_assert ( !is_transparent<std::equal_to<int>>::value, "" );
39 static_assert ( !is_transparent<std::equal_to<std::string>>::value, "" );
40 static_assert ( is_transparent<std::equal_to<void>>::value, "" );
41 static_assert ( is_transparent<std::equal_to<>>::value, "" );
42
43 static_assert ( !is_transparent<std::not_equal_to<int>>::value, "" );
44 static_assert ( !is_transparent<std::not_equal_to<std::string>>::value, "" );
45 static_assert ( is_transparent<std::not_equal_to<void>>::value, "" );
46 static_assert ( is_transparent<std::not_equal_to<>>::value, "" );
47
48 static_assert ( !is_transparent<std::greater<int>>::value, "" );
49 static_assert ( !is_transparent<std::greater<std::string>>::value, "" );
50 static_assert ( is_transparent<std::greater<void>>::value, "" );
51 static_assert ( is_transparent<std::greater<>>::value, "" );
52
53 static_assert ( !is_transparent<std::greater_equal<int>>::value, "" );
54 static_assert ( !is_transparent<std::greater_equal<std::string>>::value, "" );
55 static_assert ( is_transparent<std::greater_equal<void>>::value, "" );
56 static_assert ( is_transparent<std::greater_equal<>>::value, "" );
57
58 return 0;
59 }
60