MIRA
VariadicMacro.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_VARIADICMACRO_H_
48 #define _MIRA_VARIADICMACRO_H_
49 
50 #include <boost/version.hpp>
51 
52 #if BOOST_VERSION >= 104900
53 #include <boost/preprocessor/variadic/size.hpp>
54 #endif
55 
57 
58 #ifdef BOOST_PP_VARIADICS
59  #if BOOST_PP_VARIADICS
60  #define MIRA_VARIADIC_SIZE BOOST_PP_VARIADIC_SIZE
61  #endif
62 #endif
63 
65 
66 #ifndef MIRA_VARIADIC_SIZE
67 
68  #define GET_0(...) "__________ Error: Variable argument ('...') needs at least one parameter! __________"
69  #define GET_1(i1, ...) i1
70  #define GET_2(i1, i2, ...) i2
71  #define GET_3(i1, i2, i3, ...) i3
72  #define GET_4(i1, i2, i3, i4, ...) i4
73  #define GET_5(i1, i2, i3, i4, i5, ...) i5
74  #define GET_6(i1, i2, i3, i4, i5, i6, ...) i6
75  #define GET_7(i1, i2, i3, i4, i5, i6, i7, ...) i7
76  #define GET_8(i1, i2, i3, i4, i5, i6, i7, i8, ...) i8
77  #define GET_9(i1, i2, i3, i4, i5, i6, i7, i8, i9, ...) i9
78  #define GET_10(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, ...) i10
79  #define GET_11(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, ...) i11
80  #define GET_12(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, ...) i12
81  #define GET_13(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, ...) i13
82  #define GET_14(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, ...) i14
83  #define GET_15(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, ...) i15
84  #define GET_16(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, ...) i16
85  #define GET_17(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, ...) i17
86  #define GET_18(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, ...) i18
87  #define GET_19(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, ...) i19
88  #define GET_20(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, ...) i20
89  #define GET_21(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, ...) i21
90  #define GET_22(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, ...) i22
91  #define GET_23(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23, ...) i23
92  #define GET_24(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23, i24, ...) i24
93 
94  #define GET_N(N, ...) GET_##N(__VA_ARGS__)
95 
96  #define MIRA_VARIADIC_SIZE(...) GET_N(24, __VA_ARGS__, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
97 #endif
98 
100 
101 #endif