2 // (C) Copyright Edward Diener 2011-2015
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 #if !defined(BOOST_VMD_IDENTITY_HPP)
8 #define BOOST_VMD_IDENTITY_HPP
10 #include <boost/vmd/detail/setup.hpp>
12 #if BOOST_PP_VARIADICS
15 #include <boost/preprocessor/cat.hpp>
17 #include <boost/vmd/empty.hpp>
21 The succeeding comments in this file are in doxygen format.
28 /** \def BOOST_VMD_IDENTITY(item)
30 \brief Macro which expands to its argument when invoked with any number of parameters.
32 item = any single argument
34 When BOOST_VMD_IDENTITY(item) is subsequently invoked with any number of parameters it expands
35 to 'item'. Subsequently invoking the macro is done as 'BOOST_VMD_IDENTITY(item)(zero_or_more_arguments)'.
37 The macro is equivalent to the Boost PP macro BOOST_PP_IDENTITY(item) with the difference
38 being that BOOST_PP_IDENTITY(item) is always invoked with no arguments, as in
39 'BOOST_VMD_IDENTITY(item)()' whereas BOOST_VMD_IDENTITY can be invoked with any number of
42 The macro is meant to be used in BOOST_PP_IF and BOOST_PP_IIF statements when only one
43 of the clauses needs to be invoked with calling another macro and the other is meant to
46 returns = the macro as 'BOOST_VMD_IDENTITY(item)', when invoked with any number of parameters
47 as in '(zero_or_more_arguments)', returns 'item'. The macro itself returns
48 'item BOOST_VMD_EMPTY'.
52 #define BOOST_VMD_IDENTITY(item) item BOOST_VMD_EMPTY
54 /** \def BOOST_VMD_IDENTITY_RESULT(result)
56 \brief Macro which wraps any result which can return its value using BOOST_VMD_IDENTITY or 'item BOOST_VMD_EMPTY'.
58 result = any single result returned when BOOST_VMD_IDENTITY is used or 'item BOOST_VMD_EMPTY'.
60 The reason for this macro is to smooth over a problem when using VC++ with BOOST_VMD_IDENTITY.
61 If your BOOST_VMD_IDENTITY macro can be used where VC++ is the compiler then you need to
62 surround your macro code which could return a result with this macro in order that VC++ handles
63 BOOST_VMD_IDENTITY correctly.
65 If you are not using VC++ you do not have to use this macro, but doing so does no harm.
70 #define BOOST_VMD_IDENTITY_RESULT(result) BOOST_PP_CAT(result,)
72 #define BOOST_VMD_IDENTITY_RESULT(result) result
75 #endif /* BOOST_PP_VARIADICS */
76 #endif /* BOOST_VMD_IDENTITY_HPP */