paren.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/utility/identity_type
  6. #include <boost/utility/identity_type.hpp>
  7. #include <boost/static_assert.hpp>
  8. #include <boost/type_traits/is_const.hpp>
  9. #include <map>
  10. //[paren
  11. #define TMP_ASSERT_PAREN(parenthesized_metafunction) \
  12. /* use `BOOST_IDENTITY_TYPE` in macro definition instead of invocation */ \
  13. BOOST_STATIC_ASSERT(BOOST_IDENTITY_TYPE(parenthesized_metafunction)::value)
  14. #define TMP_ASSERT(metafunction) \
  15. BOOST_STATIC_ASSERT(metafunction::value)
  16. // Specify only extra parenthesis `((...))`.
  17. TMP_ASSERT_PAREN((boost::is_const<std::map<int, char> const>));
  18. // Specify both the extra parenthesis `((...))` and `BOOST_IDENTITY_TYPE` macro.
  19. TMP_ASSERT(BOOST_IDENTITY_TYPE((boost::is_const<std::map<int, char> const>)));
  20. //]
  21. //[paren_always
  22. TMP_ASSERT_PAREN((boost::is_const<int const>)); // Always extra `((...))`.
  23. TMP_ASSERT(boost::is_const<int const>); // No extra `((...))` and no macro.
  24. //]
  25. int main() { return 0; }