Created
April 23, 2023 18:22
-
-
Save pfirsich/e5e2c43ef8816f40bb8029ac8f7fb54a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <string> | |
#include <spdlog/spdlog.h> | |
template <typename Derived> | |
struct DebugLogging { | |
DebugLogging() { spdlog::info("{} constructed", debugId()); } | |
~DebugLogging() { spdlog::info("{} destructed", debugId()); } | |
DebugLogging(const DebugLogging& other) | |
{ | |
spdlog::info("{} copied from {}", debugId(), const_cast<DebugLogging&>(other).debugId()); | |
} | |
DebugLogging(DebugLogging&& other) | |
{ | |
spdlog::info( | |
"{} move-constructed from {}", debugId(), const_cast<DebugLogging&>(other).debugId()); | |
} | |
DebugLogging& operator=(const DebugLogging& other) | |
{ | |
spdlog::info("{} assigned from {}", debugId(), const_cast<DebugLogging&>(other).debugId()); | |
return *this; | |
} | |
DebugLogging& operator=(DebugLogging&& other) | |
{ | |
spdlog::info( | |
"{} move-assigned from {}", debugId(), const_cast<DebugLogging&>(other).debugId()); | |
return *this; | |
} | |
auto debugId() { return static_cast<Derived*>(this)->debugId(); } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment