billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
640 stars 93 forks source link

Registering a type with multiple template arguments fails #34

Closed Weeena closed 8 years ago

Weeena commented 8 years ago

If you have a class with two template parameters, e.g.

template <typename T, typename U>
class TestClass
{
public:
    U foo(T param);
};

registering this class to ponder with e.g.

PONDER_TYPE(TestClass<int, int>);

fails. (In my environment, which is VS2015, I get

warning C4002: too many actual parameters for macro 'PONDER_TYPE'

error C2976: 'TestClass': too few template arguments

A possible fix could be to define PONDER_TYPE with a variadic macro like this:

#define PONDER_TYPE(...) \
    namespace ponder \
    { \
        namespace detail \
        { \
            template <> struct StaticTypeId<__VA_ARGS__> \
            { \
                static const char* get(bool = true) {return #__VA_ARGS__;} \
                enum {defined = true, copyable = true}; \
            }; \
        } \
    }
billyquith commented 8 years ago

This should be fixed in master latest.