Mapping bracket operator for template classes
Closed this issue · 1 comments
termi-official commented
For a MWE I modified TestTemplate2, using the following header file:
namespace A {
template<typename T>
class A {
public:
A(): a(0){}
T getval(){ return a;}
void setval(const T& val){ a = val; }
T& operator[](int i) { return a; }
T a;
};
template class A<int>;
}
This fails for me with a capture error:
libTestTemplate3/src/jlTestTemplate3.cxx:46:3: error: 'this' cannot be implicitly captured in this context
module_.set_override_module(jl_base_module);
^
libTestTemplate3/src/jlTestTemplate3.cxx:33:29: note: explicitly capture 'this'
auto t0_decl_methods = []<typename T> (jlcxx::TypeWrapper<A::A<T>> wrapped){
^
this
libTestTemplate3/src/jlTestTemplate3.cxx:46:3: error: 'this' cannot be implicitly captured in this context
module_.set_override_module(jl_base_module);
^
/home/dogiermann/.julia/artifacts/8dbf3a116981de15f84137eda9d8c478f57d07a9/include/jlcxx/module.hpp:1111:5: note: in instantiation of function template specialization 'JlA_A::add_methods()::(anonymous class)::operator()<int>' requested here
apply_ftor(TypeWrapper<AppliedT>(m_module, app_dt, app_box_dt));
^
/home/dogiermann/.julia/artifacts/8dbf3a116981de15f84137eda9d8c478f57d07a9/include/jlcxx/module.hpp:1060:34: note: in instantiation of function template specialization 'jlcxx::TypeWrapper<jlcxx::Parametric<jlcxx::TypeVar<1>>>::apply_internal<A::A<int>, (lambda at libTestTemplate3/src/jlTestTemplate3.cxx:33:28) &>' requested here
auto dummy = {this->template apply_internal<AppliedTypesT>(std::forward<FunctorT>(apply_ftor))...};
^
libTestTemplate3/src/jlTestTemplate3.cxx:63:7: note: in instantiation of function template specialization 'jlcxx::TypeWrapper<jlcxx::Parametric<jlcxx::TypeVar<1>>>::apply<A::A<int>, (lambda at libTestTemplate3/src/jlTestTemplate3.cxx:33:28) &>' requested here
t.apply<A::A<int>>(t0_decl_methods);
^
libTestTemplate3/src/jlTestTemplate3.cxx:33:29: note: explicitly capture 'this'
auto t0_decl_methods = []<typename T> (jlcxx::TypeWrapper<A::A<T>> wrapped){
^
this
For an exact reproducer: I use LLVM 13 and wrapit master.