1
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).
6
7#if !defined(BOOST_VMD_IDENTITY_HPP)
8#define BOOST_VMD_IDENTITY_HPP
9
10#include <boost/vmd/detail/setup.hpp>
11
12#if BOOST_PP_VARIADICS
13
14#if BOOST_VMD_MSVC
15#include <boost/preprocessor/cat.hpp>
16#endif
17#include <boost/vmd/empty.hpp>
18
19/*
20
21 The succeeding comments in this file are in doxygen format.
22
23*/
24
25/** \file
26*/
27
28/** \def BOOST_VMD_IDENTITY(item)
29
30 \brief Macro which expands to its argument when invoked with any number of parameters.
31
32 item = any single argument
33
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)'.
36
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
40 arguments.
41
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
44 return an 'item'.
45
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'.
49
50*/
51
52#define BOOST_VMD_IDENTITY(item) item BOOST_VMD_EMPTY
53
54/** \def BOOST_VMD_IDENTITY_RESULT(result)
55
56 \brief Macro which wraps any result which can return its value using BOOST_VMD_IDENTITY or 'item BOOST_VMD_EMPTY'.
57
58 result = any single result returned when BOOST_VMD_IDENTITY is used or 'item BOOST_VMD_EMPTY'.
59
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.
64
65 If you are not using VC++ you do not have to use this macro, but doing so does no harm.
66
67*/
68
69#if BOOST_VMD_MSVC
70#define BOOST_VMD_IDENTITY_RESULT(result) BOOST_PP_CAT(result,)
71#else
72#define BOOST_VMD_IDENTITY_RESULT(result) result
73#endif
74
75#endif /* BOOST_PP_VARIADICS */
76#endif /* BOOST_VMD_IDENTITY_HPP */
77

source code of boost/boost/vmd/identity.hpp