Skip to content

problem with typedef in templated class #72

@ErwanDemairy

Description

@ErwanDemairy

Hello,
It looks the typedefs inside a templated class are given an incorrect type in the wrapper :
If I use the following code as replacement of A.h in test/TestTemplate2

#include <string>
namespace ns{
  template<typename S>
  class B {
  public:
    typedef typename std::string String;
    void method(const String& s) {}

    S a;
  };
  template class B<int>;
}

When compiling the wrapper, it gives the following errors :

[ 50%] Building CXX object CMakeFiles/jlTestTemplate2.dir/libTestTemplate2/src/jlTestTemplate2.cxx.o
build/libTestTemplate2/src/jlTestTemplate2.cxx:43:61: error: use of class template 'ns::B' requires template arguments
   43 |       wrapped.method("method", [](WrappedType& a, const ns::B::String & arg0)->void { a.method(arg0); });
      |                                                             ^
A.h:4:9: note: template is declared here
    3 |   template<typename S>
      |   ~~~~~~~~~~~~~~~~~~~~
    4 |   class B {
      |         ^
build/libTestTemplate2/src/jlTestTemplate2.cxx:44:61: error: use of class template 'ns::B' requires template arguments
   44 |       wrapped.method("method", [](WrappedType* a, const ns::B::String & arg0)->void { a->method(arg0); });
      |                                                             ^
A.h:4:9: note: template is declared here
    3 |   template<typename S>
      |   ~~~~~~~~~~~~~~~~~~~~
    4 |   class B {
      |         ^

So, the const String& type is incorrectly replaced by ns::B::String & instead of ns::B<T>::String &.
Is there any workaround allowing to obtain the correct type in the wrapper?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions