2013-01-27 13:03:02 +00:00
|
|
|
// method 0
|
|
|
|
#define METHOD__(...) __VA_ARGS__
|
|
|
|
#define METHOD_0(F,A) F METHOD__(A)
|
2013-01-27 12:55:56 +00:00
|
|
|
|
2013-01-27 13:03:02 +00:00
|
|
|
// method 1
|
|
|
|
#define METHOD_1(F,A) F(METHOD__ A)
|
|
|
|
|
|
|
|
// method 2
|
|
|
|
#define METHOD_2(F,...) F __VA_ARGS__##[0]
|
|
|
|
|
|
|
|
// method 3
|
|
|
|
#define METHOD_3(F,...) F __VA_ARGS__
|
2013-01-02 13:16:42 +00:00
|
|
|
|
2013-01-27 13:05:01 +00:00
|
|
|
// selector
|
|
|
|
#define METHOD(I, F, ...) METHOD_##I (F, __VA_ARGS__)
|
|
|
|
|
2013-01-02 13:16:42 +00:00
|
|
|
void main() {
|
2013-01-27 13:05:01 +00:00
|
|
|
METHOD(0, print, ("Method", " <zero>\n"));
|
|
|
|
METHOD(1, print, ("Method", " <one>\n"));
|
|
|
|
METHOD(2, print, ("Method", " <two>\n"));
|
|
|
|
METHOD(3, print, ("Method", " <three>\n"));
|
2013-01-02 13:16:42 +00:00
|
|
|
}
|