diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-10-14 04:38:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-14 04:38:06 +0200 |
| commit | 8939837390193e86c52299048caec9c7722178e6 (patch) | |
| tree | db923caaec3762fbb68290fd1ae94cb1465378e7 /dev/examples/allocator_system | |
| parent | 94799223495b9842bca67e1a6ecf611cec3ee771 (diff) | |
| parent | a786997f304745ce3766a82be06dc6a5d0c2f02c (diff) | |
Merge pull request #2 from snu-systems-corp/dev
feat: scl: major refactors and new version of SCL.
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 c3cd689..169cd97 100644 --- a/dev/examples/allocator_system/allocator_system.cc +++ b/dev/examples/allocator_system/allocator_system.cc @@ -8,10 +8,11 @@ #include <lib/core/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; + scl::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"; |
