diff --git a/libuavcan/include/uavcan/util/lazy_constructor.hpp b/libuavcan/include/uavcan/util/lazy_constructor.hpp index 08ff9ab5f9..c7ae975663 100644 --- a/libuavcan/include/uavcan/util/lazy_constructor.hpp +++ b/libuavcan/include/uavcan/util/lazy_constructor.hpp @@ -58,12 +58,6 @@ class UAVCAN_EXPORT LazyConstructor } } - template struct ParamType { typedef const U& Type; }; - template struct ParamType { typedef U& Type; }; -#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 - template struct ParamType { typedef U&& Type; }; -#endif - public: LazyConstructor() : ptr_(NULL) @@ -130,50 +124,53 @@ public: // for nargs in range(1, MAX_ARGS + 1): // nums = [(x + 1) for x in range(nargs)] // l1 = ['typename P%d' % x for x in nums] -// l2 = ['typename ParamType::Type p%d' % (x, x) for x in nums] +// l2 = ['typename ParameterType::Type p%d' % (x, x) for x in nums] // l3 = ['p%d' % x for x in nums] // print(TEMPLATE % (', '.join(l1), ', '.join(l2), ', '.join(l3))) template - void construct(typename ParamType::Type p1) + void construct(typename ParameterType::Type p1) { ensureNotConstructed(); ptr_ = new (static_cast(data_.pool)) T(p1); } - template - void construct(typename ParamType::Type p1, typename ParamType::Type p2) + template + void construct(typename ParameterType::Type p1, typename ParameterType::Type p2) { ensureNotConstructed(); ptr_ = new (static_cast(data_.pool)) T(p1, p2); } - template - void construct(typename ParamType::Type p1, typename ParamType::Type p2, typename ParamType::Type p3) + template + void construct(typename ParameterType::Type p1, typename ParameterType::Type p2, + typename ParameterType::Type p3) { ensureNotConstructed(); ptr_ = new (static_cast(data_.pool)) T(p1, p2, p3); } - template - void construct(typename ParamType::Type p1, typename ParamType::Type p2, typename ParamType::Type p3, - typename ParamType::Type p4) + template + void construct(typename ParameterType::Type p1, typename ParameterType::Type p2, + typename ParameterType::Type p3, typename ParameterType::Type p4) { ensureNotConstructed(); ptr_ = new (static_cast(data_.pool)) T(p1, p2, p3, p4); } - template - void construct(typename ParamType::Type p1, typename ParamType::Type p2, typename ParamType::Type p3, - typename ParamType::Type p4, typename ParamType::Type p5) + template + void construct(typename ParameterType::Type p1, typename ParameterType::Type p2, + typename ParameterType::Type p3, typename ParameterType::Type p4, + typename ParameterType::Type p5) { ensureNotConstructed(); ptr_ = new (static_cast(data_.pool)) T(p1, p2, p3, p4, p5); } - template - void construct(typename ParamType::Type p1, typename ParamType::Type p2, typename ParamType::Type p3, - typename ParamType::Type p4, typename ParamType::Type p5, typename ParamType::Type p6) + template + void construct(typename ParameterType::Type p1, typename ParameterType::Type p2, + typename ParameterType::Type p3, typename ParameterType::Type p4, + typename ParameterType::Type p5, typename ParameterType::Type p6) { ensureNotConstructed(); ptr_ = new (static_cast(data_.pool)) T(p1, p2, p3, p4, p5, p6); diff --git a/libuavcan/include/uavcan/util/templates.hpp b/libuavcan/include/uavcan/util/templates.hpp index e2572ff3d3..b32e559d87 100644 --- a/libuavcan/include/uavcan/util/templates.hpp +++ b/libuavcan/include/uavcan/util/templates.hpp @@ -100,6 +100,15 @@ template struct RemoveReference { typedef T Type; }; template struct RemoveReference { typedef T Type; }; #endif +/** + * Parameter types + */ +template struct ParameterType { typedef const U& Type; }; +template struct ParameterType { typedef U& Type; }; +#if UAVCAN_CPP_VERSION > UAVCAN_CPP03 +template struct ParameterType { typedef U&& Type; }; +#endif + /** * Value types */