Marshall Clow | 354d39c | 2014-01-16 16:58:45 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Marshall Clow | 354d39c | 2014-01-16 16:58:45 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Asiri Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 9 | // UNSUPPORTED: c++98, c++03, c++11 |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 10 | #include <functional> |
| 11 | #include <string> |
| 12 | |
Marshall Clow | 7fc6a55 | 2019-05-31 18:35:30 +0000 | [diff] [blame^] | 13 | #include "test_macros.h" |
| 14 | |
Stephan T. Lavavej | aae6356 | 2017-08-11 20:53:53 +0000 | [diff] [blame] | 15 | template <class T> |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 16 | struct is_transparent |
| 17 | { |
| 18 | private: |
Stephan T. Lavavej | 709be5e | 2017-08-11 20:54:09 +0000 | [diff] [blame] | 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); |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 22 | public: |
Stephan T. Lavavej | 709be5e | 2017-08-11 20:54:09 +0000 | [diff] [blame] | 23 | static const bool value = sizeof(test<T>(0)) == 1; |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 27 | int main(int, char**) |
Asiri Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 28 | { |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 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 | |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 59 | return 0; |
Asiri Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 60 | } |