I have the following helper utility class defined in a header:
Util.h
struct Timer
{
std::chrono::time_point< std::chrono::steady_clock > start { std::chrono::steady_clock::now( ) };
std::chrono::time_point< std::chrono::steady_clock > end;
Timer( ) = default;
~Timer( )
{
end = std::chrono::steady_clock::now( );
std::clog << "\nTimer took " << std::chrono::duration< double, std::milli >( end - start ).count( ) << " ms\n";
}
};
Any instance of this struct is used for measuring the execution time of any arbitrary scope (using RAII since the instance gets destroyed at the end of the scope).
However, I don't use the copy/move operations of this struct.
And SonarLint shows a message: "Explicitly define or delete the missing copy constructor and copy assignment operator so that they will not be implicitly provided..."
What's the best practice when it comes to such classes? Should I delete both with = delete
? What will happen to move ctor and move operator? Should I also delete them cause I'm not using them right now? Should such a class be non-copyable, non-movable?