debug/lifetime: Add lifetime stderr printer
This adds a class that aids in debugging by printing object lifetime
information to stderr.
Change-Id: I92b904a5e6d8d98f7412769f3670c5e2091a7bc9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/meson.build b/include/meson.build
index 57a5a5e..c541513 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -3,6 +3,7 @@
install_headers(
'stdplus/cancel.hpp',
'stdplus/concepts.hpp',
+ 'stdplus/debug/lifetime.hpp',
'stdplus/exception.hpp',
'stdplus/flags.hpp',
'stdplus/function_view.hpp',
diff --git a/include/stdplus/debug/lifetime.hpp b/include/stdplus/debug/lifetime.hpp
new file mode 100644
index 0000000..e63e640
--- /dev/null
+++ b/include/stdplus/debug/lifetime.hpp
@@ -0,0 +1,22 @@
+#pragma once
+#include <source_location>
+
+namespace stdplus::debug
+{
+
+class Lifetime
+{
+ public:
+ Lifetime(std::source_location loc = std::source_location::current());
+ Lifetime(const Lifetime& other);
+ Lifetime(Lifetime&& other);
+ Lifetime& operator=(const Lifetime& other);
+ Lifetime& operator=(Lifetime&& other);
+ ~Lifetime();
+
+ private:
+ std::source_location loc;
+ std::size_t id;
+};
+
+} // namespace stdplus::debug