blob: ca57c223a2aa6813b5a8572534d01aa3b1368a38 [file] [log] [blame]
Marshall Clow354d39c2014-01-16 16:58:45 +00001//===----------------------------------------------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// 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 Clow354d39c2014-01-16 16:58:45 +00006//
7//===----------------------------------------------------------------------===//
8
Asiri Rathnayake6edc12c2016-05-28 08:57:35 +00009// UNSUPPORTED: c++98, c++03, c++11
Marshall Clow75f9aa92013-08-13 01:12:41 +000010#include <functional>
11#include <string>
12
Stephan T. Lavavejaae63562017-08-11 20:53:53 +000013template <class T>
Marshall Clow75f9aa92013-08-13 01:12:41 +000014struct is_transparent
15{
16private:
Stephan T. Lavavej709be5e2017-08-11 20:54:09 +000017 struct two {char lx; char lxx;};
18 template <class U> static two test(...);
19 template <class U> static char test(typename U::is_transparent* = 0);
Marshall Clow75f9aa92013-08-13 01:12:41 +000020public:
Stephan T. Lavavej709be5e2017-08-11 20:54:09 +000021 static const bool value = sizeof(test<T>(0)) == 1;
Marshall Clow75f9aa92013-08-13 01:12:41 +000022};
23
24
Asiri Rathnayake6edc12c2016-05-28 08:57:35 +000025int main ()
26{
Marshall Clow75f9aa92013-08-13 01:12:41 +000027 static_assert ( !is_transparent<std::plus<int>>::value, "" );
28 static_assert ( !is_transparent<std::plus<std::string>>::value, "" );
29 static_assert ( is_transparent<std::plus<void>>::value, "" );
30 static_assert ( is_transparent<std::plus<>>::value, "" );
31
32 static_assert ( !is_transparent<std::minus<int>>::value, "" );
33 static_assert ( !is_transparent<std::minus<std::string>>::value, "" );
34 static_assert ( is_transparent<std::minus<void>>::value, "" );
35 static_assert ( is_transparent<std::minus<>>::value, "" );
36
37 static_assert ( !is_transparent<std::multiplies<int>>::value, "" );
38 static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" );
39 static_assert ( is_transparent<std::multiplies<void>>::value, "" );
40 static_assert ( is_transparent<std::multiplies<>>::value, "" );
41
42 static_assert ( !is_transparent<std::divides<int>>::value, "" );
43 static_assert ( !is_transparent<std::divides<std::string>>::value, "" );
44 static_assert ( is_transparent<std::divides<void>>::value, "" );
45 static_assert ( is_transparent<std::divides<>>::value, "" );
46
47 static_assert ( !is_transparent<std::modulus<int>>::value, "" );
48 static_assert ( !is_transparent<std::modulus<std::string>>::value, "" );
49 static_assert ( is_transparent<std::modulus<void>>::value, "" );
50 static_assert ( is_transparent<std::modulus<>>::value, "" );
51
52 static_assert ( !is_transparent<std::negate<int>>::value, "" );
53 static_assert ( !is_transparent<std::negate<std::string>>::value, "" );
54 static_assert ( is_transparent<std::negate<void>>::value, "" );
55 static_assert ( is_transparent<std::negate<>>::value, "" );
Eric Fiselierd04c6852016-06-01 21:35:39 +000056
Marshall Clow75f9aa92013-08-13 01:12:41 +000057 return 0;
Asiri Rathnayake6edc12c2016-05-28 08:57:35 +000058}