Container System 0.1.0
High-performance C++20 type-safe container framework with SIMD-accelerated serialization
Loading...
Searching...
No Matches
policy_container_example.cpp File Reference
#include <kcenon/container/policy_container.h>
#include <kcenon/container/storage_policy.h>
#include <iostream>
#include <string>
Include dependency graph for policy_container_example.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 23 of file policy_container_example.cpp.

24{
25 std::cout << "=== Policy Container Example ===" << std::endl;
26
27 // 1. Dynamic storage policy (default, flexible)
28 std::cout << "\n1. Dynamic storage policy:" << std::endl;
29 basic_value_container<policy::dynamic_storage_policy> dynamic_container;
30
31 dynamic_container.set("name", "Alice");
32 dynamic_container.set("score", 95.5);
33 dynamic_container.set("level", static_cast<int64_t>(42));
34
35 std::cout << " Added 3 fields to dynamic container" << std::endl;
36 std::cout << " Size: " << dynamic_container.size() << std::endl;
37
38 // 2. Indexed storage policy (optimized for key lookup)
39 std::cout << "\n2. Indexed storage policy:" << std::endl;
40 basic_value_container<policy::indexed_storage_policy> indexed_container;
41
42 indexed_container.set("id", static_cast<int64_t>(1001));
43 indexed_container.set("status", "active");
44
45 std::cout << " Added 2 fields to indexed container" << std::endl;
46 std::cout << " Size: " << indexed_container.size() << std::endl;
47
48 // 3. StoragePolicy concept check
49 std::cout << "\n3. Storage policy traits:" << std::endl;
50 std::cout << " dynamic_storage_policy satisfies StoragePolicy: "
51 << policy::StoragePolicy<policy::dynamic_storage_policy> << std::endl;
52 std::cout << " indexed_storage_policy satisfies StoragePolicy: "
53 << policy::StoragePolicy<policy::indexed_storage_policy> << std::endl;
54
55 std::cout << "\nDone." << std::endl;
56 return 0;
57}