Marshall Clow | 354d39c | 2014-01-16 16:58:45 +0000 | [diff] [blame] | 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 | |
Asiri Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 10 | // UNSUPPORTED: c++98, c++03, c++11 |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 11 | #include <functional> |
| 12 | #include <string> |
| 13 | |
Stephan T. Lavavej | aae6356 | 2017-08-11 20:53:53 +0000 | [diff] [blame] | 14 | template <class T> |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 15 | struct is_transparent |
| 16 | { |
| 17 | private: |
Stephan T. Lavavej | 709be5e | 2017-08-11 20:54:09 +0000 | [diff] [blame] | 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); |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 21 | public: |
Stephan T. Lavavej | 709be5e | 2017-08-11 20:54:09 +0000 | [diff] [blame] | 22 | static const bool value = sizeof(test<T>(0)) == 1; |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | |
Asiri Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 26 | int main () |
| 27 | { |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 28 | static_assert ( !is_transparent<std::plus<int>>::value, "" ); |
| 29 | static_assert ( !is_transparent<std::plus<std::string>>::value, "" ); |
| 30 | static_assert ( is_transparent<std::plus<void>>::value, "" ); |
| 31 | static_assert ( is_transparent<std::plus<>>::value, "" ); |
| 32 | |
| 33 | static_assert ( !is_transparent<std::minus<int>>::value, "" ); |
| 34 | static_assert ( !is_transparent<std::minus<std::string>>::value, "" ); |
| 35 | static_assert ( is_transparent<std::minus<void>>::value, "" ); |
| 36 | static_assert ( is_transparent<std::minus<>>::value, "" ); |
| 37 | |
| 38 | static_assert ( !is_transparent<std::multiplies<int>>::value, "" ); |
| 39 | static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" ); |
| 40 | static_assert ( is_transparent<std::multiplies<void>>::value, "" ); |
| 41 | static_assert ( is_transparent<std::multiplies<>>::value, "" ); |
| 42 | |
| 43 | static_assert ( !is_transparent<std::divides<int>>::value, "" ); |
| 44 | static_assert ( !is_transparent<std::divides<std::string>>::value, "" ); |
| 45 | static_assert ( is_transparent<std::divides<void>>::value, "" ); |
| 46 | static_assert ( is_transparent<std::divides<>>::value, "" ); |
| 47 | |
| 48 | static_assert ( !is_transparent<std::modulus<int>>::value, "" ); |
| 49 | static_assert ( !is_transparent<std::modulus<std::string>>::value, "" ); |
| 50 | static_assert ( is_transparent<std::modulus<void>>::value, "" ); |
| 51 | static_assert ( is_transparent<std::modulus<>>::value, "" ); |
| 52 | |
| 53 | static_assert ( !is_transparent<std::negate<int>>::value, "" ); |
| 54 | static_assert ( !is_transparent<std::negate<std::string>>::value, "" ); |
| 55 | static_assert ( is_transparent<std::negate<void>>::value, "" ); |
| 56 | static_assert ( is_transparent<std::negate<>>::value, "" ); |
Eric Fiselier | d04c685 | 2016-06-01 21:35:39 +0000 | [diff] [blame] | 57 | |
Marshall Clow | 75f9aa9 | 2013-08-13 01:12:41 +0000 | [diff] [blame] | 58 | return 0; |
Asiri Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 59 | } |