LLNL / SAMRAI

Structured Adaptive Mesh Refinement Application Infrastructure - a scalable C++ framework for block-structured AMR application development
https://computing.llnl.gov/projects/samrai
Other
220 stars 80 forks source link

C++20 compatibility dropping templates on destructor #232

Closed PhilipDeegan closed 1 year ago

PhilipDeegan commented 1 year ago

Hi,

We're trying to see if we can upgrade safely to C++20, in doing so I got this error

pdat/NodeDataFactory.h:73:12: error: template-id not allowed for destructor
   73 |    virtual ~NodeDataFactory<TYPE>();
      |            ^
In file included from /path/to/samrai/master/include/SAMRAI/pdat/NodeDataFactory.h:170:

There's probably some places remaining that I didn't remove the templates from, but this is what was required to allow us to compile.

PhilipDeegan commented 1 year ago

I was only getting this error with GCC, CLANG doesn't seem to mind with C++20 I do think templates on the destructor definition is not necessary, unless someone can tell me otherwise?

rhornung67 commented 1 year ago

Correct. The template syntax should not be on the declaration of a destructor in a class template. However, if you provide an implementation in the class header (outside of the class definition), the template syntax is required so the compiler knows which type the destructor is being implemented for.

nselliott commented 1 year ago

I can reproduce this and posted an issue to address it. I intend to remove this everywhere, not just in the files touched here, so I'll close this PR.