1
2// Copyright (C) 2009-2012 Lorenzo Caminiti
3// Distributed under the Boost Software License, Version 1.0
4// (see accompanying file LICENSE_1_0.txt or a copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6// Home at http://www.boost.org/libs/utility/identity_type
7
8/** @file
9Wrap type expressions with round parenthesis so they can be passed to macros
10even if they contain commas.
11*/
12
13#ifndef BOOST_IDENTITY_TYPE_HPP_
14#define BOOST_IDENTITY_TYPE_HPP_
15
16#include <boost/type_traits/function_traits.hpp>
17
18/**
19@brief This macro allows to wrap the specified type expression within extra
20round parenthesis so the type can be passed as a single macro parameter even if
21it contains commas (not already wrapped within round parenthesis).
22
23@Params
24@Param{parenthesized_type,
25The type expression to be passed as macro parameter wrapped by a single set
26of round parenthesis <c>(...)</c>.
27This type expression can contain an arbitrary number of commas.
28}
29@EndParams
30
31This macro works on any C++03 compiler (it does not use variadic macros).
32
33This macro must be prefixed by <c>typename</c> when used within templates.
34Note that the compiler will not be able to automatically determine function
35template parameters when they are wrapped with this macro (these parameters
36need to be explicitly specified when calling the function template).
37
38On some compilers (like GCC), using this macro on abstract types requires to
39add and remove a reference to the specified type.
40*/
41#define BOOST_IDENTITY_TYPE(parenthesized_type) \
42 /* must NOT prefix this with `::` to work with parenthesized syntax */ \
43 boost::function_traits< void parenthesized_type >::arg1_type
44
45#endif // #include guard
46
47

source code of boost/boost/utility/identity_type.hpp