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

source code of libcxx/test/std/utilities/function.objects/comparisons/transparent.pass.cpp