8000 Methods with template-typed arguments · Issue #36 · grasph/wrapit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Methods with template-typed arguments #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
termi-official opened this issue Nov 20, 2023 · 4 comments
Closed

Methods with template-typed arguments #36

termi-official opened this issue Nov 20, 2023 · 4 comments

Comments

@termi-official
Copy link
Contributor

For this MWE I modified TestTemplate2

namespace N {

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>;

void g(A<int>& a) { }

class B {
public:
    void f(A<int>& a) { a = data; }
    A<int> data;
};

}

and set auto_veto = true in the ".wit" toml.

Interestingly, read write access for B::data is generated, but faulty, whereas B::f is skipped. I tried to track this one down myself, but I cannot exactly pin down what leads to this failure.

Using auto_veto = false and this file here

namespace N {

template<typename T>
class A {
public: 
  A(): a(0){}

  T getval(){ return a;}
  
  void setval(const T& val){ a = val; }
  T a;
};

template class A<int>;

void g(A<int>& a) { }

class B {
public:
    void f(A<int>& a) { a = data; }
    A<int> data;
};

}

generates B::F, but the access to data is still broken.

@grasph
Copy link
Owner
grasph commented Nov 20, 2023

Can you try with the new commit (38023c8) I've just pushed on the main branch? Latest development done on operator may have fixed the issue you are reporting.

Philippe.

@termi-official
Copy link
Contributor Author
termi-official commented Nov 20, 2023

Both still fails (if you namespace A).

clang-13: warning: argument unused during compilation: '-fmax-errors=3' [-Wunused-command-line-argument]
libTestTemplate3/src/jlTestTemplate3.cxx:83:49: error: no template named 'A'; did you mean 'N::A'?
    t.method("data", [](const N::B& a) -> const A<int>& { return a.data; });
                                                ^
                                                N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:84:37: error: no template named 'A'; did you mean 'N::A'?
    t.method("data", [](N::B& a) -> A<int>& { return a.data; });
                                    ^
                                    N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:85:49: error: no template named 'A'; did you mean 'N::A'?
    t.method("data", [](const N::B* a) -> const A<int>& { return a->data; });
                                                ^
                                                N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:86:37: error: no template named 'A'; did you mean 'N::A'?
    t.method("data", [](N::B* a) -> A<int>& { return a->data; });
                                    ^
                                    N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:92:41: error: no template named 'A'; did you mean 'N::A'?
    t.method("data!", [](N::B& a, const A<int>& val) -> A<int>& { return a.data = val; });
                                        ^
                                        N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:92:57: error: no template named 'A'; did you mean 'N::A'?
    t.method("data!", [](N::B& a, const A<int>& val) -> A<int>& { return a.data = val; });
                                                        ^
                                                        N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:95:41: error: no template named 'A'; did you mean 'N::A'?
    t.method("data!", [](N::B* a, const A<int>& val) -> A<int>& { return a->data = val; });
                                        ^
                                        N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
libTestTemplate3/src/jlTestTemplate3.cxx:95:57: error: no template named 'A'; did you mean 'N::A'?
    t.method("data!", [](N::B* a, const A<int>& val) -> A<int>& { return a->data = val; });
                                                        ^
                                                        N::A
./A.h:4:7: note: 'N::A' declared here
class A {
      ^
8 errors generated.
make: *** [../make.rules:39: libTestTemplate3/build/jlTestTemplate3.o] Error 1

And thanks for taking time so quickly!

@grasph
Copy link
Owner
grasph commented Nov 27, 2023

Should be fixed by the merged PR: see test/TestNamespace new unit test. Please, reopen the issue if it's not fully fixed.

@grasph grasph closed this as completed Nov 27, 2023
@termi-official
Copy link
Contributor Author

Thanks!

I am now getting very different errors, most of them related to inheritance, but I cannot find a minimal reproducer right now (tried for almost an hour now to get something). Basically I am getting errors on two types of things now:

  1. friends, e.g.
error: no candidate function template was found for dependent friend function template specialization
   friend void Swap<T>(Array<T> &, Array<T> &);
  1. inheritance, e.g.
error: cannot initialize object parameter of type 'mfem::NewtonSolver' with an expression of type 'mfem::LBFGSSolver'
      NewtonSolver::SetOperator(op);

both errors are new. I will try to bisect later this week which commit caused this.

grasph added a commit that referenced this issue Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0