add_member_volatile.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 <boost/callable_traits/detail/config.hpp>
  7. #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  8. int main(){ return 0; }
  9. #else
  10. //[ add_member_volatile
  11. #include <type_traits>
  12. #include <boost/callable_traits/add_member_volatile.hpp>
  13. namespace ct = boost::callable_traits;
  14. struct foo {};
  15. int main() {
  16. {
  17. using pmf = void(foo::*)();
  18. using expect = void(foo::*)() volatile;
  19. using test = ct::add_member_volatile_t<pmf>;
  20. static_assert(std::is_same<test, expect>::value, "");
  21. } {
  22. // add_member_volatile_t doesn't change anything when
  23. // the function type is already volatile.
  24. using pmf = void(foo::*)() volatile &&;
  25. using expect = void(foo::*)() volatile &&;
  26. using test = ct::add_member_volatile_t<pmf>;
  27. static_assert(std::is_same<test, expect>::value, "");
  28. } {
  29. using pmf = void(foo::*)() const &;
  30. using expect = void(foo::*)() const volatile &;
  31. using test = ct::add_member_volatile_t<pmf>;
  32. static_assert(std::is_same<test, expect>::value, "");
  33. } {
  34. // add_member_volatile_t can also be used with "abominable"
  35. // function types.
  36. using f = void();
  37. using expect = void() volatile;
  38. using test = ct::add_member_volatile_t<f>;
  39. static_assert(std::is_same<test, expect>::value, "");
  40. }
  41. }
  42. //]
  43. #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS