identity_type.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. /** @file
  7. Wrap type expressions with round parenthesis so they can be passed to macros
  8. even if they contain commas.
  9. */
  10. #ifndef BOOST_IDENTITY_TYPE_HPP_
  11. #define BOOST_IDENTITY_TYPE_HPP_
  12. #include <boost/type_traits/function_traits.hpp>
  13. /**
  14. @brief This macro allows to wrap the specified type expression within extra
  15. round parenthesis so the type can be passed as a single macro parameter even if
  16. it contains commas (not already wrapped within round parenthesis).
  17. @Params
  18. @Param{parenthesized_type,
  19. The type expression to be passed as macro parameter wrapped by a single set
  20. of round parenthesis <c>(...)</c>.
  21. This type expression can contain an arbitrary number of commas.
  22. }
  23. @EndParams
  24. This macro works on any C++03 compiler (it does not use variadic macros).
  25. This macro must be prefixed by <c>typename</c> when used within templates.
  26. Note that the compiler will not be able to automatically determine function
  27. template parameters when they are wrapped with this macro (these parameters
  28. need to be explicitly specified when calling the function template).
  29. On some compilers (like GCC), using this macro on abstract types requires to
  30. add and remove a reference to the specified type.
  31. */
  32. #define BOOST_IDENTITY_TYPE(parenthesized_type) \
  33. /* must NOT prefix this with `::` to work with parenthesized syntax */ \
  34. boost::function_traits< void parenthesized_type >::arg1_type
  35. #endif // #include guard