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