By analyzing code using SonarLint, I got a message (the title of the question) about a destructor that is declared like below:
class Foo
{
public:
. // default ctor
. // parameterized ctor
.
inline ~Foo() = default; // dtor
.
. // copy ctor = delete
. // copy assignment operator = delete
. // move ctor
. // move assignment operator
private:
...
mutable std::vector< std::vector<char> > m_Matrix;
...
};
Here is the message's description: Declaring a function or a static member variable constexpr makes it implicitly inline.
I don't think the dtor of this class can be constexpr or consteval because it has a non-static data member of type std::vector so ~Foo has to call delete[] at some point to deallocate the vector's storage.
So why is SonarLint showing this message? Is it because of = default? Does any defaulted special member function become implicitly constexpr?
~Foo() = default;is considered a definition, so it will be inlined automagically.m_Matrix, then they should be=defaulted, and deleted copy operations can optionally be removed, because they're deleted automatically when you have custom (or defaulted) move operations. Or, if you don't mind the class being copyable, you can remove remove both copy and move operations.