MIRA
HasNonMember.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 
46 #ifndef MIRA_HASNONMEMBER_H_
47 #define MIRA_HASNONMEMBER_H_
48 
49 // ToDo: generate variants for different parameter numbers automatically using BOOST_PP
50 
52 
53 #define MIRA_NONMEMBER_FUNCTION0_DETECTOR_EX(Identifier, ReturnType, FunctionName) \
54 template <typename = ReturnType> \
55 struct MIRAHasNonMemberCheck##Identifier \
56 { \
57  typedef std::false_type type; \
58  enum { value = false }; \
59 }; \
60  \
61 template <> \
62 struct MIRAHasNonMemberCheck##Identifier<decltype(FunctionName())> \
63 { \
64  typedef std::true_type type; \
65  enum { value = true }; \
66 };
67 
68 #define MIRA_NONMEMBER_FUNCTION0_DETECTOR(ReturnType, FunctionName) \
69  MIRA_NONMEMBER_FUNCTION0_DETECTOR_EX(FunctionName, ReturnType, FunctionName)
70 
72 
73 #define MIRA_NONMEMBER_FUNCTION1_DETECTOR_EX(Identifier, ReturnType, FunctionName) \
74 template <typename P0, typename = ReturnType> \
75 struct MIRAHasNonMemberCheck##Identifier \
76 { \
77  typedef std::false_type type; \
78  enum { value = false }; \
79 }; \
80  \
81 template <typename P0> \
82 struct MIRAHasNonMemberCheck##Identifier<P0, \
83  decltype(FunctionName(std::declval<P0>()))> \
84 { \
85  typedef std::true_type type; \
86  enum { value = true }; \
87 };
88 
89 #define MIRA_NONMEMBER_FUNCTION1_DETECTOR(ReturnType, FunctionName) \
90  MIRA_NONMEMBER_FUNCTION1_DETECTOR_EX(FunctionName, ReturnType, FunctionName)
91 
93 
94 #define MIRA_NONMEMBER_FUNCTION2_DETECTOR_EX(Identifier, ReturnType, FunctionName) \
95 template <typename P0, typename P1, typename = ReturnType> \
96 struct MIRAHasNonMemberCheck##Identifier \
97 { \
98  typedef std::false_type type; \
99  enum { value = false }; \
100 }; \
101  \
102 template <typename P0, typename P1> \
103 struct MIRAHasNonMemberCheck##Identifier<P0, P1, \
104  decltype(FunctionName(std::declval<P0>(), \
105  std::declval<P1>()))> \
106 { \
107  typedef std::true_type type; \
108  enum { value = true }; \
109 };
110 
111 #define MIRA_NONMEMBER_FUNCTION2_DETECTOR(ReturnType, FunctionName) \
112  MIRA_NONMEMBER_FUNCTION2_DETECTOR_EX(FunctionName, ReturnType, FunctionName)
113 
115 
116 #define MIRA_NONMEMBER_FUNCTION3_DETECTOR_EX(Identifier, ReturnType, FunctionName) \
117 template <typename P0, typename P1, typename P2, typename = ReturnType> \
118 struct MIRAHasNonMemberCheck##Identifier \
119 { \
120  typedef std::false_type type; \
121  enum { value = false }; \
122 }; \
123  \
124 template <typename P0, typename P1, typename P2> \
125 struct MIRAHasNonMemberCheck##Identifier<P0, P1, P2, \
126  decltype(FunctionName(std::declval<P0>(), \
127  std::declval<P1>(), \
128  std::declval<P2>()))> \
129 { \
130  typedef std::true_type type; \
131  enum { value = true }; \
132 };
133 
134 #define MIRA_NONMEMBER_FUNCTION3_DETECTOR(ReturnType, FunctionName) \
135  MIRA_NONMEMBER_FUNCTION3_DETECTOR_EX(FunctionName, ReturnType, FunctionName)
136 
138 
150 #define MIRA_HAS_NONMEMBER_FUNCTION0(Identifier) \
151  MIRAHasNonMemberCheck##Identifier<>
152 
154 
166 #define MIRA_HAS_NONMEMBER_FUNCTION1(Identifier, ParamType0) \
167  MIRAHasNonMemberCheck##Identifier<ParamType0>
168 
170 
182 #define MIRA_HAS_NONMEMBER_FUNCTION2(Identifier, ParamType0, ParamType1) \
183  MIRAHasNonMemberCheck##Identifier<ParamType0, ParamType1>
184 
186 
198 #define MIRA_HAS_NONMEMBER_FUNCTION3(Identifier, ParamType0, ParamType1, ParamType2) \
199  MIRAHasNonMemberCheck##Identifier<ParamType0, ParamType1, ParamType2>
200 
202 
203 #endif