Do C++ compilers generate a def ctor if the class was not initialized?

I have written a utility class (acts as a helper class, I guess) that has only a few static member functions to be used in another class. It does not have any non-static members (variables or functions). So it also doesn’t have any explicit ctors or dtor.

And the question is, does my compiler (GCC v11.2 and -std=c++20) still generate an implicit default ctor and a dtor for the utility class? If it does, then how should I prevent it from doing so? since I haven’t initialized any instance of that class in my code.

Answer

(I’m slightly side-stepping your question in lieu of providing unsolicited advice) If you have a collection of static functions and your class does not require any state

class Example
{
public:
    static void Foo();
    static int Bar();
};

then you should likely not be using a class in the first place, rather these should probably be free functions in a namespace

namespace Example
{
    void Foo();
    int Bar();
}

which still allows you to invoke them as Example::Foo() and Example::Bar() but now you don’t have to worry about someone trying to instantiate your “class” since that’s not what you intended to design it for.