1 #ifndef VARIADICMACROS_H
2 #define VARIADICMACROS_H
14 #define STATIC_VARIADIC_TO_VECTOR_PART1(functionName, inputType, outputType) \
15 template<typename... Args> \
16 inline static argument_type<void(outputType)>::type functionName(Args const&... args) { \
17 std::vector< argument_type<void(inputType)>::type> vec; \
18 return functionName(vec, args...); \
21 #define STATIC_VARIADIC_TO_VECTOR_PART2(functionName, inputType, outputType) \
22 template<typename... Args> \
23 inline static argument_type<void(outputType)>::type functionName(std::vector<argument_type<void(inputType)>::type>& bounds, argument_type<void(inputType)>::type const& ith, Args const&... args) { \
24 bounds.push_back(ith); \
25 return functionName(bounds, args...); \
27 inline static argument_type<void(outputType)>::type functionName(std::vector<argument_type<void(inputType)>::type>& bounds, argument_type<void(inputType)>::type const& last) { \
28 bounds.push_back(last); \
29 return functionName(bounds); \
32 #define STATIC_VARIADIC_TO_VECTOR(functionName, inputType, outputType) \
33 STATIC_VARIADIC_TO_VECTOR_PART1(functionName, inputType, outputType) \
34 STATIC_VARIADIC_TO_VECTOR_PART2(functionName, inputType, outputType)
36 #define VARIADIC_TO_VECTOR(functionName, inputType, outputType) \
37 template<typename... Args> \
38 inline argument_type<void(outputType)>::type functionName(Args const&... args) { \
39 std::vector< argument_type<void(inputType)>::type> vec; \
40 return functionName(vec, args...); \
42 template<typename NextType, typename... Args> \
43 inline argument_type<void(outputType)>::type functionName(std::vector<argument_type<void(inputType)>::type>& bounds, NextType const& ith, Args const&... args) { \
44 static_assert(std::is_same<argument_type<void(inputType)>::type, NextType>::value, "In "#functionName", cannot cast input to "#inputType"."); \
45 bounds.push_back((argument_type<void(inputType)>::type&)ith); \
46 return functionName(bounds, args...); \
48 inline argument_type<void(outputType)>::type functionName(std::vector<argument_type<void(inputType)>::type>& bounds, argument_type<void(inputType)>::type const& last) { \
49 bounds.push_back(last); \
50 return functionName(bounds); \
53 #define VARIADIC_TO_REFVECTOR(functionName, inputType, outputType) \
54 template<typename... Args> \
55 inline argument_type<void(outputType)>::type functionName(Args const&... args) { \
56 ref_vector< argument_type<void(inputType)>::type> vec; \
57 return functionName(vec, args...); \
59 template<typename NextType, typename... Args> \
60 inline argument_type<void(outputType)>::type functionName(ref_vector<argument_type<void(inputType)>::type>& bounds, NextType const& ith, Args const&... args) { \
61 static_assert(std::is_same<argument_type<void(inputType)>::type, NextType>::value, "In "#functionName", cannot cast input to "#inputType"."); \
62 bounds.push_back(std::cref((argument_type<void(inputType)>::type&)ith)); \
63 return functionName(bounds, args...); \
65 inline argument_type<void(outputType)>::type functionName(ref_vector<argument_type<void(inputType)>::type>& bounds, argument_type<void(inputType)>::type const& last) { \
66 bounds.push_back(std::cref(last)); \
67 return functionName(bounds); \