billyquith / ponder

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

Declaring templated class to ponder fails #24

Closed Weeena closed 8 years ago

Weeena commented 8 years ago

If I have some template class e.g.

template <class T>
class CTestClass
{
public:
    T testMember_;
};

and like to declare this class to ponder with e.g.

PONDER_TYPE(CTestClass<int>)

void declare_CTestClass()
{
    ponder::Class::declare<CTestClass<int>>("CIntTestClass")
        .constructor();
        .property("TestMember", &CTesteClass<int>::testMember_);
}

I get several compiler errors (I can post you details if you think it is necessary).

To me it seems that the reason for the failure is detail::IsSmartPointer: detail::IsSmartPointer erroneously detects my templated class as a smart pointer, hence parts of ponder assume that the desired type is int rather than CTestClass<int>. This leads to compiler errors of the kind that there is no conversion between CTestClass<int>* and int*.

billyquith commented 8 years ago

Thanks. Which platform/compiler are you using? Be interested to see the errors. Working on a fix.

billyquith commented 8 years ago

Ok, have checked a fix in, with tests. Let me know if that works for you.

Weeena commented 8 years ago

Once again thank you for your super quick reaction. And - yes, it works for me! By the way: For development, our primary platform is Windows, VS2015. But our project is required to run on Linux, too, there we have Eclipse and gcc 4.8 (I hope I got this right).

billyquith commented 8 years ago

Thanks. Useful to know platform details. I do want the library portable. I'm a Mac user on clang. Had some issues with earlier versions of MSVC. Lots of subtle bugs. I think C++11 support there lags the others. All seems to work at the moment.