summaryrefslogtreecommitdiffhomepage
path: root/examples/tracked_ptr/tracked_ptr.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-18 11:02:04 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-18 11:02:04 +0100
commitc44d6912bc2f37e8d1c239cfb9981bd5cd366c58 (patch)
tree13ba46b3f3aa1d82e45a3cfde79b80ab4abc4864 /examples/tracked_ptr/tracked_ptr.cc
parent142a0bc12ac8178ba7a3ac824a92c775ce6afbba (diff)
feat: tracked_ptr class and system.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples/tracked_ptr/tracked_ptr.cc')
-rw-r--r--examples/tracked_ptr/tracked_ptr.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/tracked_ptr/tracked_ptr.cc b/examples/tracked_ptr/tracked_ptr.cc
new file mode 100644
index 0000000..be88d17
--- /dev/null
+++ b/examples/tracked_ptr/tracked_ptr.cc
@@ -0,0 +1,29 @@
+/*
+ tracked_ptr example
+ written by Amlal El Mahrouss.
+ licensed under the MIT license
+ */
+
+#include <lib/memory/tracked_ptr.hpp>
+#include <iostream>
+
+void foo()
+{
+ snu::memory::tracked_ptr<int> ptr9;
+}
+
+/* finally test it */
+int main(int argc, char** argv)
+{
+ foo();
+ foo();
+ foo();
+ foo();
+
+ snu::memory::tracked_ptr<int> ptr;
+
+ std::cout << ptr.manager().allocator().allocated_count_ << std::endl;
+ std::cout << ptr.manager().allocator().deallocated_count_ << std::endl;
+
+ return 0;
+}