PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc

https://bitbucket.org/bluezoo/gcc
C++ | 740 lines | 607 code | 103 blank | 30 comment | 0 complexity | d614b3f4261de924421d22c90169c972 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0, GPL-3.0, BSD-3-Clause, LGPL-2.0
  1. // { dg-options "-std=gnu++11" }
  2. // { dg-do compile }
  3. // Copyright (C) 2012 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library. This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. // You should have received a copy of the GNU General Public License along
  15. // with this library; see the file COPYING3. If not see
  16. // <http://www.gnu.org/licenses/>.
  17. #include <memory>
  18. #include <cstddef>
  19. #include <type_traits>
  20. // TODO: Uncomment the following define once gcc has fixed bug 52748
  21. // (incomplete types in function call expressions):
  22. //#define HAS_52748_FIXED
  23. // Helper types:
  24. struct has_type_impl
  25. {
  26. template<typename T, typename = typename T::type>
  27. static std::true_type test(int);
  28. template<typename>
  29. static std::false_type test(...);
  30. };
  31. template<typename T>
  32. struct has_type : public decltype(has_type_impl::test<T>(0))
  33. {};
  34. template<typename T, typename Res>
  35. struct is_expected_type : public std::is_same<typename T::type, Res>
  36. {};
  37. template<typename P1, typename P2>
  38. struct and_ : public std::conditional<P1::value, P2, std::false_type>::type
  39. {};
  40. template<typename T, typename Res>
  41. struct is_type : public and_<has_type<T>, is_expected_type<T, Res>>
  42. {};
  43. // Types under inspection:
  44. typedef bool (&PF1)();
  45. typedef short (*PF2)(long);
  46. struct S {
  47. operator PF2() const;
  48. double operator()(char, int&);
  49. void calc(long) const;
  50. };
  51. typedef void (S::*PMS)(long) const;
  52. typedef void (S::*PMSnonconst)(long);
  53. typedef int S::* PMI;
  54. struct B {
  55. int i;
  56. void f1() const;
  57. bool f2(int) const volatile;
  58. };
  59. struct D : B {};
  60. typedef void (B::*base_func_void)() const;
  61. typedef bool (B::*base_func_bool_int)(int) const volatile;
  62. struct ident_functor {
  63. template<typename T>
  64. T operator()(T&& x);
  65. };
  66. template<typename Ret = void>
  67. struct variable_functor {
  68. template<typename... T>
  69. Ret operator()(T&&...);
  70. };
  71. struct ident_functor_noref {
  72. template<typename T>
  73. typename std::remove_reference<T>::type operator()(T&& x);
  74. };
  75. enum class ScEn;
  76. enum UnScEn : int;
  77. union U {
  78. int i;
  79. double d;
  80. };
  81. union U2 {
  82. int i;
  83. bool b;
  84. void operator()() const;
  85. int operator()(double) const;
  86. bool operator()(double);
  87. U operator()(int, int);
  88. };
  89. struct Ukn;
  90. typedef Ukn (S::*PMSIncomplete)(long) const;
  91. typedef Ukn (S::*PMSIncompletenonconst)(long);
  92. typedef Ukn (*FuncIncomplete)(long);
  93. struct Abstract {
  94. virtual ~Abstract() = 0;
  95. };
  96. struct Private {
  97. private:
  98. void operator()();
  99. int operator()(int);
  100. public:
  101. bool operator()(std::nullptr_t);
  102. };
  103. union PrivateUnion {
  104. double d;
  105. private:
  106. void operator()();
  107. int operator()(int);
  108. public:
  109. bool operator()(std::nullptr_t);
  110. };
  111. template<typename T>
  112. struct ImplicitTo {
  113. operator T();
  114. };
  115. template<typename>
  116. struct never { static const bool value = false; };
  117. template<typename T>
  118. struct BrokenTrait {
  119. static_assert(never<T>::value, "Error!");
  120. typedef T type;
  121. };
  122. template<typename T>
  123. struct BadSmartPtr : T {
  124. T& operator*() const noexcept(typename BrokenTrait<T>::type());
  125. };
  126. template<typename Ret>
  127. using FuncEllipses = Ret(...);
  128. static_assert(is_type<std::result_of<S(int)>, short>::value, "Error!");
  129. static_assert(is_type<std::result_of<S&(unsigned char, int&)>,
  130. double>::value, "Error!");
  131. static_assert(is_type<std::result_of<PF1()>, bool>::value, "Error!");
  132. static_assert(is_type<std::result_of<PF1&()>, bool>::value, "Error!");
  133. static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>,
  134. void>::value, "Error!");
  135. static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>&, unsigned&)>,
  136. void>::value, "Error!");
  137. static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>, int)>,
  138. void>::value, "Error!");
  139. static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>&, unsigned&)>,
  140. void>::value, "Error!");
  141. static_assert(is_type<std::result_of<ident_functor(int)>,
  142. int>::value, "Error!");
  143. static_assert(is_type<std::result_of<ident_functor(const int)>,
  144. int>::value, "Error!");
  145. static_assert(is_type<std::result_of<ident_functor(const int&&)>,
  146. int>::value, "Error!");
  147. static_assert(is_type<std::result_of<ident_functor(int&&)>,
  148. int>::value, "Error!");
  149. static_assert(is_type<std::result_of<ident_functor(int&)>,
  150. int&>::value, "Error!");
  151. static_assert(is_type<std::result_of<ident_functor(const B)>,
  152. B>::value, "Error!");
  153. static_assert(is_type<std::result_of<ident_functor(const B&&)>,
  154. const B>::value, "Error!");
  155. static_assert(is_type<std::result_of<ident_functor(B&&)>, B>::value, "Error!");
  156. static_assert(is_type<std::result_of<ident_functor(B&)>, B&>::value, "Error!");
  157. static_assert(is_type<std::result_of<int B::*(B&)>, int&>::value, "Error!");
  158. // This is expected as of CWG 616 P/R:
  159. static_assert(is_type<std::result_of<int B::*(B)>, int&&>::value, "Error!");
  160. static_assert(is_type<std::result_of<volatile int B::*(const B&&)>,
  161. const volatile int&&>::value, "Error!");
  162. static_assert(is_type<std::result_of<const int B::*(volatile B&&)>,
  163. const volatile int&&>::value, "Error!");
  164. static_assert(is_type<std::result_of<int B::*(const B&)>,
  165. const int&>::value, "Error!");
  166. static_assert(is_type<std::result_of<volatile int B::*(const B&)>,
  167. const volatile int&>::value, "Error!");
  168. static_assert(is_type<std::result_of<const int B::*(volatile B&)>,
  169. const volatile int&>::value, "Error!");
  170. static_assert(is_type<std::result_of<int B::*(B*)>, int&>::value, "Error!");
  171. static_assert(is_type<std::result_of<int B::*(B*&)>, int&>(), "Error!");
  172. static_assert(is_type<std::result_of<int B::*(const B*)>,
  173. const int&>::value, "Error!");
  174. static_assert(is_type<std::result_of<int B::*(const B*&)>,
  175. const int&>::value, "Error!");
  176. static_assert(is_type<std::result_of<volatile int B::*(const B*)>,
  177. const volatile int&>::value, "Error!");
  178. static_assert(is_type<std::result_of<const int B::*(volatile B*)>,
  179. const volatile int&>::value, "Error!");
  180. static_assert(is_type<std::result_of<base_func_void(const B&)>,
  181. void>::value, "Error!");
  182. static_assert(is_type<std::result_of<base_func_void(const B*)>,
  183. void>::value, "Error!");
  184. static_assert(is_type<std::result_of<base_func_void(B&)>,
  185. void>::value, "Error!");
  186. static_assert(is_type<std::result_of<base_func_void(B*)>,
  187. void>::value, "Error!");
  188. static_assert(!has_type<std::result_of<base_func_void(volatile B&)>>::value,
  189. "Error!");
  190. static_assert(!has_type<std::result_of<base_func_void(volatile B*)>>::value,
  191. "Error!");
  192. static_assert(is_type<std::result_of<base_func_bool_int(B&, long)>,
  193. bool>::value, "Error!");
  194. static_assert(is_type<std::result_of<base_func_bool_int(B*, long)>,
  195. bool>::value, "Error!");
  196. static_assert(is_type<std::result_of<base_func_bool_int(volatile B&, long)>,
  197. bool>::value, "Error!");
  198. static_assert(is_type<std::result_of<base_func_bool_int(volatile B*, long)>,
  199. bool>::value, "Error!");
  200. static_assert(!has_type<std::result_of<int()>>(), "Error!");
  201. static_assert(!has_type<std::result_of<void()>>(), "Error!");
  202. static_assert(!has_type<std::result_of<int(int)>>(), "Error!");
  203. static_assert(!has_type<std::result_of<void(int)>>(), "Error!");
  204. static_assert(!has_type<std::result_of<PF1(int)>>(), "Error!");
  205. static_assert(is_type<std::result_of<PF2(long)>, short>(), "Error!");
  206. static_assert(!has_type<std::result_of<PF2()>>(), "Error!");
  207. static_assert(!has_type<std::result_of<PF2(B)>>(), "Error!");
  208. static_assert(!has_type<std::result_of<PF2(ScEn)>>(), "Error!");
  209. static_assert(is_type<std::result_of<PF2(UnScEn)>, short>(), "Error!");
  210. static_assert(!has_type<std::result_of<PF2(long, int)>>(), "Error!");
  211. static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>, void>(),
  212. "Error!");
  213. static_assert(!has_type<std::result_of<PMS(int)>>(), "Error!");
  214. static_assert(!has_type<std::result_of<PMS(int, std::unique_ptr<S>)>>(), "Error!");
  215. // Argument number mismatch:
  216. static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>)>>(), "Error!");
  217. static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&)>>(), "Error!");
  218. static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, int, bool)>>(),
  219. "Error!");
  220. static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, int, bool)>>(),
  221. "Error!");
  222. static_assert(!has_type<std::result_of<PMS(S)>>(), "Error!");
  223. static_assert(!has_type<std::result_of<PMS(S&)>>(), "Error!");
  224. static_assert(!has_type<std::result_of<PMS(S, int, bool)>>(), "Error!");
  225. static_assert(!has_type<std::result_of<PMS(S&, int, bool)>>(), "Error!");
  226. // Non-convertible arguments:
  227. static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, S)>>(),
  228. "Error!");
  229. static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, S)>>(),
  230. "Error!");
  231. static_assert(!has_type<std::result_of<PMS(S, S)>>(), "Error!");
  232. static_assert(!has_type<std::result_of<PMS(S&, S)>>(), "Error!");
  233. // cv-violations:
  234. static_assert(!has_type<std::result_of<PMSnonconst(const S&, long)>>(),
  235. "Error!");
  236. static_assert(!has_type<std::result_of<PMSnonconst(const S&&, long)>>(),
  237. "Error!");
  238. static_assert(!has_type<std::result_of<PMSnonconst(const S*, long)>>(),
  239. "Error!");
  240. static_assert(!has_type<std::result_of<PMSnonconst(const S*&, long)>>(),
  241. "Error!");
  242. static_assert(is_type<std::result_of<PMI(S*)>, int&>(), "Error!");
  243. static_assert(is_type<std::result_of<PMI(S&)>, int&>(), "Error!");
  244. static_assert(is_type<std::result_of<PMI(S&&)>, int&&>(), "Error!");
  245. static_assert(is_type<std::result_of<PMI(S)>, int&&>(), "Error!");
  246. static_assert(!has_type<std::result_of<PMI()>>(), "Error!");
  247. static_assert(!has_type<std::result_of<PMI(S*, int)>>(), "Error!");
  248. static_assert(!has_type<std::result_of<PMI(S&, int)>>(), "Error!");
  249. static_assert(!has_type<std::result_of<PMI(S*, int, S, bool)>>(), "Error!");
  250. static_assert(!has_type<std::result_of<PMI(S&, int, S, bool)>>(), "Error!");
  251. static_assert(!has_type<std::result_of<PMI(B*)>>(), "Error!");
  252. static_assert(!has_type<std::result_of<PMI(B&)>>(), "Error!");
  253. static_assert(is_type<std::result_of<int U::*(U)>, int&&>(), "Error!");
  254. static_assert(is_type<std::result_of<int U::*(U&)>, int&>(), "Error!");
  255. static_assert(is_type<std::result_of<int U::*(const U&)>, const int&>(),
  256. "Error!");
  257. static_assert(is_type<std::result_of
  258. <volatile int U::*(const U&)>, const volatile int&>(), "Error!");
  259. static_assert(is_type<std::result_of
  260. <const int U::*(volatile U&)>, const volatile int&>(), "Error!");
  261. static_assert(is_type<std::result_of<int Ukn::*(Ukn*)>, int&>(), "Error!");
  262. static_assert(is_type<std::result_of<int Ukn::*(Ukn&)>, int&>(), "Error!");
  263. static_assert(is_type<std::result_of<int Ukn::*(Ukn&&)>, int&&>(), "Error!");
  264. static_assert(is_type<std::result_of<int Ukn::*(const Ukn*)>, const int&>(),
  265. "Error!");
  266. static_assert(is_type<std::result_of<int Ukn::*(const Ukn&)>, const int&>(),
  267. "Error!");
  268. static_assert(is_type<std::result_of<int Ukn::*(const Ukn&&)>, const int&&>(),
  269. "Error!");
  270. typedef void (Ukn::* PUfnMF)();
  271. typedef void (Ukn::* PUfnConstMF)() const;
  272. static_assert(is_type<std::result_of<PUfnMF(Ukn*)>, void>(), "Error!");
  273. static_assert(is_type<std::result_of<PUfnMF(Ukn&)>, void>(), "Error!");
  274. static_assert(is_type<std::result_of<PUfnMF(Ukn&&)>, void>(), "Error!");
  275. static_assert(is_type<std::result_of<PUfnConstMF(Ukn*)>, void>(), "Error!");
  276. static_assert(is_type<std::result_of<PUfnConstMF(Ukn&)>, void>(), "Error!");
  277. static_assert(is_type<std::result_of<PUfnConstMF(Ukn&&)>, void>(), "Error!");
  278. static_assert(is_type<std::result_of<PUfnConstMF(const Ukn*)>, void>(),
  279. "Error!");
  280. static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&)>, void>(),
  281. "Error!");
  282. static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&&)>, void>(),
  283. "Error!");
  284. static_assert(!has_type<std::result_of<S()>>(), "Error!");
  285. static_assert(!has_type<std::result_of<S(int, S)>>(), "Error!");
  286. static_assert(!has_type<std::result_of<S(S)>>(), "Error!");
  287. static_assert(!has_type<std::result_of
  288. <S(double, bool, std::nullptr_t, Ukn&)>>(), "Error!");
  289. static_assert(is_type<std::result_of<U2()>, void>(), "Error!");
  290. static_assert(is_type<std::result_of<const U2&()>, void>(), "Error!");
  291. static_assert(is_type<std::result_of<U2&()>, void>(), "Error!");
  292. static_assert(is_type<std::result_of<U2(double)>, bool>(), "Error!");
  293. static_assert(is_type<std::result_of<const U2&(double)>, int>(), "Error!");
  294. static_assert(is_type<std::result_of<U2&(double)>, bool>(), "Error!");
  295. static_assert(is_type<std::result_of<U2(int)>, bool>(), "Error!");
  296. static_assert(is_type<std::result_of<U2&(int)>, bool>(), "Error!");
  297. static_assert(is_type<std::result_of<const U2&(int)>, int>(), "Error!");
  298. static_assert(is_type<std::result_of<U2(int, int)>, U>(), "Error!");
  299. static_assert(is_type<std::result_of<U2&(int, int)>, U>(), "Error!");
  300. static_assert(!has_type<std::result_of<const U2&(int, int)>>(), "Error!");
  301. static_assert(!has_type<std::result_of<U2(int, int, int)>>(), "Error!");
  302. static_assert(!has_type<std::result_of<U2&(int, int, int)>>(), "Error!");
  303. static_assert(!has_type<std::result_of<const U2&(int, int, int)>>(), "Error!");
  304. static_assert(is_type<std::result_of<ident_functor(int)>, int>(), "Error!");
  305. static_assert(is_type<std::result_of<ident_functor(const volatile int)>,
  306. int>(), "Error!");
  307. static_assert(is_type<std::result_of<ident_functor(int&)>, int&>(), "Error!");
  308. static_assert(is_type<std::result_of<ident_functor(const volatile int&)>,
  309. const volatile int&>(), "Error!");
  310. static_assert(is_type<std::result_of<ident_functor(int&&)>, int>(), "Error!");
  311. static_assert(is_type<std::result_of<ident_functor(const volatile int&&)>,
  312. int>(), "Error!");
  313. static_assert(is_type<std::result_of<ident_functor(Abstract&)>, Abstract&>(),
  314. "Error!");
  315. static_assert(is_type<std::result_of<ident_functor(const volatile Abstract&)>,
  316. const volatile Abstract&>(), "Error!");
  317. static_assert(!has_type<std::result_of<ident_functor(int(&&)[1])>>(), "Error!");
  318. static_assert(!has_type<std::result_of<ident_functor(Abstract&&)>>(), "Error!");
  319. static_assert(!has_type<std::result_of<ident_functor(const int(&&)[1])>>(),
  320. "Error!");
  321. static_assert(!has_type<std::result_of<ident_functor(const Abstract&&)>>(),
  322. "Error!");
  323. static_assert(!has_type<std::result_of<ident_functor_noref(int(&)[1])>>(),
  324. "Error!");
  325. static_assert(!has_type<std::result_of<ident_functor_noref
  326. (const int(&)[1])>>(), "Error!");
  327. static_assert(!has_type<std::result_of<ident_functor_noref(Abstract&)>>(),
  328. "Error!");
  329. static_assert(!has_type<std::result_of
  330. <ident_functor_noref(const Abstract&)>>(), "Error!");
  331. static_assert(!has_type<std::result_of<ident_functor_noref(void(&)())>>(),
  332. "Error!");
  333. static_assert(!has_type<std::result_of<ident_functor_noref(void(&&)())>>(),
  334. "Error!");
  335. static_assert(!has_type<std::result_of<ident_functor()>>(), "Error!");
  336. static_assert(!has_type<std::result_of<ident_functor(int, int)>>(), "Error!");
  337. static_assert(!has_type<std::result_of<const ident_functor&(int)>>(), "Error!");
  338. static_assert(!has_type<std::result_of<const ident_functor&&(int)>>(),
  339. "Error!");
  340. // Border-line case:
  341. static_assert(!has_type<std::result_of<int S::*(Ukn*)>>(), "Error!");
  342. static_assert(!has_type<std::result_of<void (S::*(Ukn*))()>>(), "Error!");
  343. // We want to allow this, it seems to be required by the order described
  344. // in [func.require] p1:
  345. static_assert(is_type<std::result_of<int S::*(BadSmartPtr<S>&)>, int&>(),
  346. "Error!");
  347. static_assert(is_type<std::result_of<Private(std::nullptr_t)>, bool>(),
  348. "Error!");
  349. static_assert(is_type<std::result_of<Private&(std::nullptr_t)>, bool>(),
  350. "Error!");
  351. static_assert(is_type<std::result_of<Private&&(std::nullptr_t)>, bool>(),
  352. "Error!");
  353. static_assert(is_type<std::result_of<Private(ImplicitTo<std::nullptr_t>)>,
  354. bool>(), "Error!");
  355. static_assert(is_type<std::result_of<Private&(ImplicitTo<std::nullptr_t>)>,
  356. bool>(), "Error!");
  357. static_assert(is_type<std::result_of<Private&&(ImplicitTo<std::nullptr_t>)>,
  358. bool>(), "Error!");
  359. static_assert(!has_type<std::result_of<const Private&(std::nullptr_t)>>(),
  360. "Error!");
  361. static_assert(!has_type<std::result_of<const Private&&(std::nullptr_t)>>(),
  362. "Error!");
  363. static_assert(!has_type<std::result_of<Private()>>(), "Error!");
  364. static_assert(!has_type<std::result_of<Private(int)>>(), "Error!");
  365. static_assert(!has_type<std::result_of<Private(int, int)>>(), "Error!");
  366. static_assert(!has_type<std::result_of<Private&()>>(), "Error!");
  367. static_assert(!has_type<std::result_of<Private&(int)>>(), "Error!");
  368. static_assert(!has_type<std::result_of<Private&(int, int)>>(), "Error!");
  369. static_assert(!has_type<std::result_of<const Private&()>>(), "Error!");
  370. static_assert(!has_type<std::result_of<const Private&(int)>>(), "Error!");
  371. static_assert(!has_type<std::result_of<const Private&(int, int)>>(), "Error!");
  372. static_assert(!has_type<std::result_of<Private&&()>>(), "Error!");
  373. static_assert(!has_type<std::result_of<Private&&(int)>>(), "Error!");
  374. static_assert(!has_type<std::result_of<Private&&(int, int)>>(), "Error!");
  375. static_assert(!has_type<std::result_of<const Private&&()>>(), "Error!");
  376. static_assert(!has_type<std::result_of<const Private&&(int)>>(), "Error!");
  377. static_assert(!has_type<std::result_of<const Private&&(int, int)>>(), "Error!");
  378. static_assert(!has_type<std::result_of<Private(ScEn)>>(), "Error!");
  379. static_assert(!has_type<std::result_of<Private(UnScEn)>>(), "Error!");
  380. static_assert(!has_type<std::result_of<const Private&(ScEn)>>(), "Error!");
  381. static_assert(!has_type<std::result_of<const Private&(UnScEn)>>(), "Error!");
  382. static_assert(!has_type<std::result_of<Private(ImplicitTo<ScEn>)>>(), "Error!");
  383. static_assert(!has_type<std::result_of<Private(ImplicitTo<UnScEn>)>>(),
  384. "Error!");
  385. static_assert(!has_type<std::result_of<const Private&(ImplicitTo<ScEn>)>>(),
  386. "Error!");
  387. static_assert(!has_type<std::result_of<const Private&(ImplicitTo<UnScEn>)>>(),
  388. "Error!");
  389. static_assert(is_type<std::result_of<PrivateUnion(std::nullptr_t)>, bool>(),
  390. "Error!");
  391. static_assert(is_type<std::result_of<PrivateUnion&(std::nullptr_t)>, bool>(),
  392. "Error!");
  393. static_assert(is_type<std::result_of<PrivateUnion&&(std::nullptr_t)>, bool>(),
  394. "Error!");
  395. static_assert(is_type<std::result_of<PrivateUnion(ImplicitTo<std::nullptr_t>)>,
  396. bool>(), "Error!");
  397. static_assert(is_type<std::result_of
  398. <PrivateUnion&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!");
  399. static_assert(is_type<std::result_of
  400. <PrivateUnion&&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!");
  401. static_assert(!has_type<std::result_of<const PrivateUnion&(std::nullptr_t)>>(),
  402. "Error!");
  403. static_assert(!has_type<std::result_of
  404. <const PrivateUnion&&(std::nullptr_t)>>(), "Error!");
  405. static_assert(!has_type<std::result_of<PrivateUnion()>>(), "Error!");
  406. static_assert(!has_type<std::result_of<PrivateUnion(int)>>(), "Error!");
  407. static_assert(!has_type<std::result_of<PrivateUnion(int, int)>>(), "Error!");
  408. static_assert(!has_type<std::result_of<PrivateUnion&()>>(), "Error!");
  409. static_assert(!has_type<std::result_of<PrivateUnion&(int)>>(), "Error!");
  410. static_assert(!has_type<std::result_of<PrivateUnion&(int, int)>>(), "Error!");
  411. static_assert(!has_type<std::result_of<const PrivateUnion&()>>(), "Error!");
  412. static_assert(!has_type<std::result_of<const PrivateUnion&(int)>>(), "Error!");
  413. static_assert(!has_type<std::result_of<const PrivateUnion&(int, int)>>(),
  414. "Error!");
  415. static_assert(!has_type<std::result_of<PrivateUnion&&()>>(), "Error!");
  416. static_assert(!has_type<std::result_of<PrivateUnion&&(int)>>(), "Error!");
  417. static_assert(!has_type<std::result_of<PrivateUnion&&(int, int)>>(), "Error!");
  418. static_assert(!has_type<std::result_of<const PrivateUnion&&()>>(), "Error!");
  419. static_assert(!has_type<std::result_of<const PrivateUnion&&(int)>>(), "Error!");
  420. static_assert(!has_type<std::result_of<const PrivateUnion&&(int, int)>>(),
  421. "Error!");
  422. static_assert(!has_type<std::result_of<PrivateUnion(ScEn)>>(), "Error!");
  423. static_assert(!has_type<std::result_of<PrivateUnion(UnScEn)>>(), "Error!");
  424. static_assert(!has_type<std::result_of<const PrivateUnion&(ScEn)>>(), "Error!");
  425. static_assert(!has_type<std::result_of<const PrivateUnion&(UnScEn)>>(),
  426. "Error!");
  427. static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<ScEn>)>>(),
  428. "Error!");
  429. static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<UnScEn>)>>(),
  430. "Error!");
  431. static_assert(!has_type<std::result_of
  432. <const PrivateUnion&(ImplicitTo<ScEn>)>>(), "Error!");
  433. static_assert(!has_type<std::result_of
  434. <const PrivateUnion&(ImplicitTo<UnScEn>)>>(), "Error!");
  435. static_assert(is_type<std::result_of<void(*(bool))(int)>, void>(), "Error!");
  436. static_assert(is_type<std::result_of<void(*(UnScEn))(int)>, void>(), "Error!");
  437. static_assert(is_type<std::result_of<void(*(ImplicitTo<int>))(int)>, void>(),
  438. "Error!");
  439. static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&))(int)>, void>(),
  440. "Error!");
  441. static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&&))(int)>, void>(),
  442. "Error!");
  443. static_assert(!has_type<std::result_of<void(*(ScEn))(int)>>(), "Error!");
  444. static_assert(!has_type<std::result_of
  445. <void(*(const ImplicitTo<int>&))(int)>>(), "Error!");
  446. static_assert(!has_type<std::result_of
  447. <void(*(const ImplicitTo<int>&&))(int)>>(), "Error!");
  448. static_assert(is_type<std::result_of<ImplicitTo<void(*)()>()>, void>(),
  449. "Error!");
  450. static_assert(is_type<std::result_of<ImplicitTo<void(&)()>()>, void>(),
  451. "Error!");
  452. static_assert(!has_type<std::result_of<ImplicitTo<void(*)()>(int)>>(),
  453. "Error!");
  454. static_assert(!has_type<std::result_of<ImplicitTo<void(*)(int)>()>>(),
  455. "Error!");
  456. static_assert(!has_type<std::result_of<ImplicitTo<void(&)()>(int)>>(),
  457. "Error!");
  458. static_assert(!has_type<std::result_of<ImplicitTo<void(&)(int)>()>>(),
  459. "Error!");
  460. // Conversion operators of types are not considered in call expressions
  461. // (except for conversion to function pointer/reference):
  462. static_assert(!has_type<std::result_of<ImplicitTo<S>(char, int&)>>(), "Error!");
  463. static_assert(!has_type<std::result_of<ImplicitTo<ident_functor>(int)>>(),
  464. "Error!");
  465. static_assert(is_type<std::result_of<variable_functor<>()>, void>(), "Error!");
  466. static_assert(is_type<std::result_of<variable_functor<>(int)>, void>(),
  467. "Error!");
  468. static_assert(is_type<std::result_of<variable_functor<>(int, int)>, void>(),
  469. "Error!");
  470. static_assert(is_type<std::result_of<variable_functor<>(int, int, int)>,
  471. void>(), "Error!");
  472. static_assert(is_type<std::result_of<variable_functor<>&()>, void>(), "Error!");
  473. static_assert(is_type<std::result_of<variable_functor<>&(int)>, void>(),
  474. "Error!");
  475. static_assert(is_type<std::result_of<variable_functor<>&(int, int)>, void>(),
  476. "Error!");
  477. static_assert(is_type<std::result_of<variable_functor<>&(int, int, int)>,
  478. void>(), "Error!");
  479. static_assert(!has_type<std::result_of<const variable_functor<>()>>(),
  480. "Error!");
  481. static_assert(!has_type<std::result_of<const variable_functor<>(int)>>(),
  482. "Error!");
  483. static_assert(!has_type<std::result_of<const variable_functor<>(int, int)>>(),
  484. "Error!");
  485. static_assert(!has_type<std::result_of
  486. <const variable_functor<>(int, int, int)>>(), "Error!");
  487. static_assert(!has_type<std::result_of<const variable_functor<>&()>>(),
  488. "Error!");
  489. static_assert(!has_type<std::result_of<const variable_functor<>&(int)>>(),
  490. "Error!");
  491. static_assert(!has_type<std::result_of
  492. <const variable_functor<>&(int, int)>>(), "Error!");
  493. static_assert(!has_type<std::result_of
  494. <const variable_functor<>&(int, int, int)>>(), "Error!");
  495. static_assert(is_type<std::result_of<variable_functor<S>()>, S>(), "Error!");
  496. static_assert(is_type<std::result_of<variable_functor<S>(int)>, S>(), "Error!");
  497. static_assert(is_type<std::result_of<variable_functor<S>(int, int)>, S>(),
  498. "Error!");
  499. static_assert(is_type<std::result_of<variable_functor<S>(int, int, int)>, S>(),
  500. "Error!");
  501. static_assert(is_type<std::result_of<variable_functor<S>&()>, S>(), "Error!");
  502. static_assert(is_type<std::result_of<variable_functor<S>&(int)>, S>(),
  503. "Error!");
  504. static_assert(is_type<std::result_of<variable_functor<S>&(int, int)>, S>(),
  505. "Error!");
  506. static_assert(is_type<std::result_of
  507. <variable_functor<S>&(int, int, int)>, S>(), "Error!");
  508. static_assert(!has_type<std::result_of
  509. <const variable_functor<S>()>>(), "Error!");
  510. static_assert(!has_type<std::result_of
  511. <const variable_functor<S>(int)>>(), "Error!");
  512. static_assert(!has_type<std::result_of
  513. <const variable_functor<S>(int, int)>>(), "Error!");
  514. static_assert(!has_type<std::result_of
  515. <const variable_functor<S>(int, int, int)>>(), "Error!");
  516. static_assert(!has_type<std::result_of<const variable_functor<S>&()>>(),
  517. "Error!");
  518. static_assert(!has_type<std::result_of<const variable_functor<S>&(int)>>(),
  519. "Error!");
  520. static_assert(!has_type<std::result_of
  521. <const variable_functor<S>&(int, int)>>(), "Error!");
  522. static_assert(!has_type<std::result_of
  523. <const variable_functor<S>&(int, int, int)>>(), "Error!");
  524. #if defined(HAS_52748_FIXED)
  525. static_assert(has_type<std::result_of<variable_functor<Ukn>()>>(), "Error!");
  526. static_assert(is_type<std::result_of<variable_functor<Ukn>()>, Ukn>(),
  527. "Error!");
  528. static_assert(is_type<std::result_of<variable_functor<Ukn>(int)>, Ukn>(),
  529. "Error!");
  530. static_assert(is_type<std::result_of<variable_functor<Ukn>(int, int)>, Ukn>(),
  531. "Error!");
  532. static_assert(is_type<std::result_of
  533. <variable_functor<Ukn>(int, int, int)>, Ukn>(), "Error!");
  534. static_assert(is_type<std::result_of<variable_functor<Ukn>&()>, Ukn>(),
  535. "Error!");
  536. static_assert(is_type<std::result_of<variable_functor<Ukn>&(int)>, Ukn>(),
  537. "Error!");
  538. static_assert(is_type<std::result_of
  539. <variable_functor<Ukn>&(int, int)>, Ukn>(), "Error!");
  540. static_assert(is_type<std::result_of
  541. <variable_functor<Ukn>&(int, int, int)>, Ukn>(), "Error!");
  542. static_assert(is_type<std::result_of<PMSIncomplete(int)>, Ukn>(), "Error!");
  543. static_assert(is_type<std::result_of<PMSIncomplete&(int)>, Ukn>(), "Error!");
  544. static_assert(is_type<std::result_of<PMSIncomplete&&(int)>, Ukn>(), "Error!");
  545. static_assert(is_type<std::result_of<FuncIncomplete(int)>, Ukn>(), "Error!");
  546. static_assert(is_type<std::result_of<FuncIncomplete&(int)>, Ukn>(), "Error!");
  547. static_assert(is_type<std::result_of<FuncIncomplete&&(int)>, Ukn>(), "Error!");
  548. static_assert(is_type<std::result_of<FuncEllipses<Ukn>*()>, Ukn>(), "Error!");
  549. static_assert(is_type<std::result_of<FuncEllipses<Ukn>&()>, Ukn>(), "Error!");
  550. static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&()>, Ukn>(), "Error!");
  551. static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool)>, Ukn>(),
  552. "Error!");
  553. static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool)>, Ukn>(),
  554. "Error!");
  555. static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&(bool)>, Ukn>(),
  556. "Error!");
  557. static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool, int, S)>, Ukn>(),
  558. "Error!");
  559. static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool, int, S)>, Ukn>(),
  560. "Error!");
  561. static_assert(is_type<std::result_of
  562. <FuncEllipses<Ukn>&&(bool, int, S)>, Ukn>(), "Error!");
  563. static_assert(!has_type<std::result_of<PMSIncompletenonconst(const S*)>>(),
  564. "Error!");
  565. static_assert(!has_type<std::result_of
  566. <PMSIncompletenonconst(const S*, int)>>(), "Error!");
  567. static_assert(!has_type<std::result_of
  568. <PMSIncompletenonconst(const S*, int, int)>>(), "Error!");
  569. static_assert(!has_type<std::result_of
  570. <PMSIncompletenonconst(const S*, int, int, int)>>(), "Error!");
  571. static_assert(!has_type<std::result_of
  572. <PMSIncompletenonconst(const S*&)>>(), "Error!");
  573. static_assert(!has_type<std::result_of
  574. <PMSIncompletenonconst(const S*&, int)>>(), "Error!");
  575. static_assert(!has_type<std::result_of
  576. <PMSIncompletenonconst(const S*&, int, int)>>(), "Error!");
  577. static_assert(!has_type<std::result_of
  578. <PMSIncompletenonconst(const S*&, int, int, int)>>(), "Error!");
  579. static_assert(!has_type<std::result_of
  580. <PMSIncompletenonconst(const S&)>>(), "Error!");
  581. static_assert(!has_type<std::result_of
  582. <PMSIncompletenonconst(const S&, int)>>(), "Error!");
  583. static_assert(!has_type<std::result_of
  584. <PMSIncompletenonconst(const S&, int, int)>>(), "Error!");
  585. static_assert(!has_type<std::result_of
  586. <PMSIncompletenonconst(const S&, int, int, int)>>(), "Error!");
  587. static_assert(!has_type<std::result_of
  588. <PMSIncompletenonconst(const S&&)>>(), "Error!");
  589. static_assert(!has_type<std::result_of
  590. <PMSIncompletenonconst(const S&&, int)>>(), "Error!");
  591. static_assert(!has_type<std::result_of
  592. <PMSIncompletenonconst(const S&&, int, int)>>(), "Error!");
  593. static_assert(!has_type<std::result_of
  594. <PMSIncompletenonconst(const S&&, int, int, int)>>(), "Error!");
  595. #endif
  596. static_assert(!has_type<std::result_of<const variable_functor<Ukn>()>>(),
  597. "Error!");
  598. static_assert(!has_type<std::result_of<const variable_functor<Ukn>(int)>>(),
  599. "Error!");
  600. static_assert(!has_type<std::result_of
  601. <const variable_functor<Ukn>(int, int)>>(), "Error!");
  602. static_assert(!has_type<std::result_of
  603. <const variable_functor<Ukn>(int, int, int)>>(), "Error!");
  604. static_assert(!has_type<std::result_of<const variable_functor<Ukn>&()>>(),
  605. "Error!");
  606. static_assert(!has_type<std::result_of<const variable_functor<Ukn>&(int)>>(),
  607. "Error!");
  608. static_assert(!has_type<std::result_of
  609. <const variable_functor<Ukn>&(int, int)>>(), "Error!");
  610. static_assert(!has_type<std::result_of
  611. <const variable_functor<Ukn>&(int, int, int)>>(), "Error!");
  612. static_assert(!has_type<std::result_of<FuncIncomplete()>>(), "Error!");
  613. static_assert(!has_type<std::result_of<FuncIncomplete(S)>>(), "Error!");
  614. static_assert(!has_type<std::result_of<FuncIncomplete(int, int)>>(), "Error!");
  615. static_assert(!has_type<std::result_of<FuncIncomplete(int, int, int)>>(),
  616. "Error!");
  617. static_assert(!has_type<std::result_of<FuncIncomplete&&()>>(), "Error!");
  618. static_assert(!has_type<std::result_of<FuncIncomplete&&(S)>>(), "Error!");
  619. static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int)>>(),
  620. "Error!");
  621. static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int, int)>>(),
  622. "Error!");
  623. static_assert(is_type<std::result_of<FuncEllipses<int>*()>, int>(), "Error!");
  624. static_assert(is_type<std::result_of<FuncEllipses<int>&()>, int>(), "Error!");
  625. static_assert(is_type<std::result_of<FuncEllipses<int>&&()>, int>(), "Error!");
  626. static_assert(is_type<std::result_of<FuncEllipses<int>*(bool)>, int>(),
  627. "Error!");
  628. static_assert(is_type<std::result_of<FuncEllipses<int>&(bool)>, int>(),
  629. "Error!");
  630. static_assert(is_type<std::result_of<FuncEllipses<int>&&(bool)>, int>(),
  631. "Error!");
  632. static_assert(is_type<std::result_of<FuncEllipses<int>*(bool, int, S)>, int>(),
  633. "Error!");
  634. static_assert(is_type<std::result_of<FuncEllipses<int>&(bool, int, S)>, int>(),
  635. "Error!");
  636. static_assert(is_type<std::result_of
  637. <FuncEllipses<int>&&(bool, int, S)>, int>(), "Error!");