{"id":20968562,"url":"https://github.com/rnburn/bbai-kernel","last_synced_at":"2025-10-10T03:38:03.312Z","repository":{"id":70477516,"uuid":"184336049","full_name":"rnburn/bbai-kernel","owner":"rnburn","description":"C++ components used in the project https://github.com/rnburn/bbai","archived":false,"fork":false,"pushed_at":"2023-09-04T05:31:40.000Z","size":180,"stargazers_count":51,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T16:25:16.615Z","etag":null,"topics":["cpp","cpp20","memory-allocation","performance","polymorphic-allocators"],"latest_commit_sha":null,"homepage":"https://buildingblock.ai/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rnburn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-04-30T21:48:01.000Z","updated_at":"2024-10-23T02:45:44.000Z","dependencies_parsed_at":"2023-09-04T22:30:15.977Z","dependency_job_id":null,"html_url":"https://github.com/rnburn/bbai-kernel","commit_stats":null,"previous_names":["rnburn/bbai-lib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Fbbai-kernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Fbbai-kernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Fbbai-kernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Fbbai-kernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rnburn","download_url":"https://codeload.github.com/rnburn/bbai-kernel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254112605,"owners_count":22016806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp20","memory-allocation","performance","polymorphic-allocators"],"created_at":"2024-11-19T03:14:16.525Z","updated_at":"2025-10-10T03:37:58.282Z","avatar_url":"https://github.com/rnburn.png","language":"C++","readme":"# bbai-kernel\n\n![](https://github.com/rnburn/bbai-mem/workflows/pr-build-test/badge.svg) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nbbai-kernel is a modern C++ library with components for reflection and building allocator aware types.\n\nIt is a small piece of the project [bbai](https://github.com/rnburn/bbai) that provides algorithms\nfor deterministic objective Bayesian analysis.\n\n## Documentation\n* [How to Implement Reflection With an Inline Macro](https://buildingblock.ai/reflection)\n* [How to Build an Allocator-aware Smart Pointer](https://buildingblock.ai/allocator-aware-smart-ptr)\n* [How to Make Your C++ Code Faster With Extended Stack Space](https://buildingblock.ai/extended-stack)\n* [How to Compose Allocator-aware Types](https://buildingblock.ai/allocator-aware-composition)\n\n## Quick start\n\n```cpp\n#include \u003carray\u003e\n#include \u003ccassert\u003e\n#include \u003ciostream\u003e\n#include \u003cmemory_resource\u003e\n\n#include \"bbai/memory/management/managed_ptr.h\"\n#include \"bbai/memory/management/managed_ptr_utility.h\"\n\nstruct A {\n  virtual ~A() noexcept = default;\n\n  virtual int f() const noexcept = 0;\n};\n\nstruct B final : public A {\n  explicit B(int xx) : x{xx} {}\n  int x;\n\n  int f() const noexcept override { return x; }\n};\n\nint main() {\n  std::array\u003cchar, 100\u003e buffer;\n  std::pmr::monotonic_buffer_resource resource{static_cast\u003cvoid*\u003e(buffer.data()),\n                                               buffer.size()};\n\n  bbai::memmg::managed_ptr\u003cA\u003e ptr1{\u0026resource};\n    // we configure ptr1 to allocate into buffer\n\n  std::pmr::polymorphic_allocator\u003c\u003e alloc;\n  bbai::memmg::managed_ptr\u003cA\u003e ptr2 = \n            bbai::memmg::allocate_managed\u003cB\u003e(alloc, 123);\n    // ptr2 manages memory from the heap\n\n  ptr1 = std::move(ptr2); \n    // because the two pointers have unequal allocators, the assignment will\n    // reallocate memory and move construct an instance of B into buffer\n\n  std::cout \u003c\u003c (reinterpret_cast\u003cchar*\u003e(ptr1.get()) == buffer.data()) \u003c\u003c \"\\n\"; \n    // prints 1\n  std::cout \u003c\u003c ptr1-\u003ef() \u003c\u003c std::endl; // prints 123\n\n  return 0;\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnburn%2Fbbai-kernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frnburn%2Fbbai-kernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnburn%2Fbbai-kernel/lists"}