diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-17 10:45:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-17 10:45:15 +0100 |
| commit | 5abec5514a0745b8032d8c60f5752529e4a13eaa (patch) | |
| tree | c91152ab4cc3a56fbb74d44dc801be5cb8ad3787 /dev/examples/allocator_system | |
| parent | c6b7510cdb9350c4e129bfcd7959efc4daee9df6 (diff) | |
| parent | 4700f4d91c342276cc2663f149ed7a8b4e8f3498 (diff) | |
Merge pull request #8 from amlel-el-mahrouss/developv1.0.45
release: Mojave
Diffstat (limited to 'dev/examples/allocator_system')
| -rw-r--r-- | dev/examples/allocator_system/allocator_system.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/dev/examples/allocator_system/allocator_system.cc b/dev/examples/allocator_system/allocator_system.cc index 67c3aca..6e7bc6d 100644 --- a/dev/examples/allocator_system/allocator_system.cc +++ b/dev/examples/allocator_system/allocator_system.cc @@ -8,10 +8,11 @@ #include <lib/memory/allocator_system.hpp> #include <iostream> -struct MyClass +class MyClass final { - int a; - std::string b; +public: + int a{}; + std::string b{}; MyClass() : a(0), b("default") { @@ -31,17 +32,19 @@ struct MyClass int main() { - using Alloc = ocl::standard_allocator_type<MyClass>; - Alloc allocator; + ocl::standard_allocator_type<MyClass> allocator; // Test 1: claim() + unclaim() std::cout << "=== Test 1: claim/unclaim ===\n"; + MyClass* raw = allocator.claim(); + std::cout << "raw->a = " << raw->a << ", raw->b = " << raw->b << "\n"; allocator.unclaim(raw); // Manual delete // Test 2: construct() → shared_ptr std::cout << "\n=== Test 2: construct (shared_ptr) ===\n"; + auto ptr = allocator.construct<int, std::string>(42, "hello"); std::cout << "ptr->a = " << ptr->a << ", ptr->b = " << ptr->b << "\n"; |
