add_member_volatile.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Copyright Barrett Adair 2016-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt)
  5. */
  6. #include <type_traits>
  7. #include <functional>
  8. #include <tuple>
  9. #include <boost/callable_traits/add_member_volatile.hpp>
  10. #include "test.hpp"
  11. struct foo{};
  12. int main() {
  13. {
  14. using f = int(foo::*)(int);
  15. using l = int(foo::*)(int) LREF;
  16. using r = int(foo::*)(int) RREF;
  17. using c = int(foo::*)(int) const;
  18. using cl = int(foo::*)(int) const LREF;
  19. using cr = int(foo::*)(int) const RREF;
  20. using v = int(foo::*)(int) volatile;
  21. using vl = int(foo::*)(int) volatile LREF;
  22. using vr = int(foo::*)(int) volatile RREF;
  23. using cv = int(foo::*)(int) const volatile;
  24. using cvl = int(foo::*)(int) const volatile LREF;
  25. using cvr = int(foo::*)(int) const volatile RREF;
  26. CT_ASSERT(std::is_same<v, TRAIT(add_member_volatile, f)>{});
  27. CT_ASSERT(std::is_same<v, TRAIT(add_member_volatile, v)>{});
  28. CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, l)>{});
  29. CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, vl)>{});
  30. CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, r)>{});
  31. CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, vr)>{});
  32. CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, c)>{});
  33. CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, cv)>{});
  34. CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cl)>{});
  35. CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cvl)>{});
  36. CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cr)>{});
  37. CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cvr)>{});
  38. }
  39. #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  40. {
  41. using f = foo();
  42. using l = foo() LREF;
  43. using r = foo() RREF;
  44. using c = foo() const;
  45. using cl = foo() const LREF;
  46. using cr = foo() const RREF;
  47. using v = foo() volatile;
  48. using vl = foo() volatile LREF;
  49. using vr = foo() volatile RREF;
  50. using cv = foo() const volatile;
  51. using cvl = foo() const volatile LREF;
  52. using cvr = foo() const volatile RREF;
  53. CT_ASSERT(std::is_same<v, TRAIT(add_member_volatile, f)>{});
  54. CT_ASSERT(std::is_same<v, TRAIT(add_member_volatile, v)>{});
  55. CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, l)>{});
  56. CT_ASSERT(std::is_same<vl, TRAIT(add_member_volatile, vl)>{});
  57. CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, r)>{});
  58. CT_ASSERT(std::is_same<vr, TRAIT(add_member_volatile, vr)>{});
  59. CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, c)>{});
  60. CT_ASSERT(std::is_same<cv, TRAIT(add_member_volatile, cv)>{});
  61. CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cl)>{});
  62. CT_ASSERT(std::is_same<cvl, TRAIT(add_member_volatile, cvl)>{});
  63. CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cr)>{});
  64. CT_ASSERT(std::is_same<cvr, TRAIT(add_member_volatile, cvr)>{});
  65. }
  66. #endif
  67. }