All Projects → rnburn → bbai-lib

rnburn / bbai-lib

Licence: Apache-2.0 license
C++ library for getting the most out of polymorphic allocators

Programming Languages

C++
36643 projects - #6 most used programming language
Starlark
911 projects

Projects that are alternatives of or similar to bbai-lib

Rmm
RAPIDS Memory Manager
Stars: ✭ 154 (+275.61%)
Mutual labels:  memory-allocation
USmallFlat
Ubpa small flat containers based on C++20
Stars: ✭ 20 (-51.22%)
Mutual labels:  cpp20
gal
Geometric Algebra Library
Stars: ✭ 78 (+90.24%)
Mutual labels:  cpp20
cpp20-internet-client
An HTTP(S) client library for C++20.
Stars: ✭ 34 (-17.07%)
Mutual labels:  cpp20
valkyrie
🔮 A UNIX-like toy kernel built from scratch (for AArch64) with preemptive multi-threading, VM, CoW fork(), buddy, slob, VFS, FAT32.
Stars: ✭ 57 (+39.02%)
Mutual labels:  cpp20
recursive-variant
Recursive Variant: A simple library for Recursive Variant Types
Stars: ✭ 67 (+63.41%)
Mutual labels:  cpp20
Libmemory
Embedded systems memory management library. Implementations for malloc(), free(), and other useful memory management functions
Stars: ✭ 102 (+148.78%)
Mutual labels:  memory-allocation
Script
Script is an object-oriented interpreted programming language. Being migrated to CppUtils
Stars: ✭ 18 (-56.1%)
Mutual labels:  cpp20
among-us-replay-mod
Replay mod for Among Us
Stars: ✭ 48 (+17.07%)
Mutual labels:  cpp20
BackportCpp
Library of backported modern C++ types to work with C++11
Stars: ✭ 53 (+29.27%)
Mutual labels:  cpp20
zab
C++20 liburing backed coroutine executor and event loop framework.
Stars: ✭ 54 (+31.71%)
Mutual labels:  cpp20
buddy alloc
A single header buddy memory allocator for C
Stars: ✭ 46 (+12.2%)
Mutual labels:  memory-allocation
RTX-Mesh-Shaders
Different mesh shading techniques using the NVIDIA RTX (Turing) technology.
Stars: ✭ 84 (+104.88%)
Mutual labels:  cpp20
Dlib
Allocators, I/O streams, math, geometry, image and audio processing for D
Stars: ✭ 182 (+343.9%)
Mutual labels:  memory-allocation
opzioni
The wanna-be-simplest command line arguments library for C++
Stars: ✭ 29 (-29.27%)
Mutual labels:  cpp20
Heapinspector For Ios
Find memory issues & leaks in your iOS app without instruments
Stars: ✭ 1,819 (+4336.59%)
Mutual labels:  memory-allocation
MeetixOS
An hobby OS written in modern C++20 which aims to be Unix-like. Currently based on EvangelionNG, a GhostOS derived kernel
Stars: ✭ 179 (+336.59%)
Mutual labels:  cpp20
json5
Header only JSON/JSON5 parser and serializer for C++
Stars: ✭ 22 (-46.34%)
Mutual labels:  cpp20
photon mapping
minimal but extensible header only implementation of photon mapping in C++
Stars: ✭ 65 (+58.54%)
Mutual labels:  cpp20
mulle-allocator
🔄 Flexible C memory allocation scheme
Stars: ✭ 77 (+87.8%)
Mutual labels:  memory-allocation

bbai-mem

License

bbai-lib is a modern C++ library with components for reflection and building allocator aware types.

Documentation

Quick start

#include <array>
#include <cassert>
#include <iostream>
#include <memory_resource>

#include "bbai/memory/management/managed_ptr.h"
#include "bbai/memory/management/managed_ptr_utility.h"

struct A {
  virtual ~A() noexcept = default;

  virtual int f() const noexcept = 0;
};

struct B final : public A {
  explicit B(int xx) : x{xx} {}
  int x;

  int f() const noexcept override { return x; }
};

int main() {
  std::array<char, 100> buffer;
  std::pmr::monotonic_buffer_resource resource{static_cast<void*>(buffer.data()),
                                               buffer.size()};

  bbai::memmg::managed_ptr<A> ptr1{&resource};
    // we configure ptr1 to allocate into buffer

  std::pmr::polymorphic_allocator<> alloc;
  bbai::memmg::managed_ptr<A> ptr2 = 
            bbai::memmg::allocate_managed<B>(alloc, 123);
    // ptr2 manages memory from the heap

  ptr1 = std::move(ptr2); 
    // because the two pointers have unequal allocators, the assignment will
    // reallocate memory and move construct an instance of B into buffer

  std::cout << (reinterpret_cast<char*>(ptr1.get()) == buffer.data()) << "\n"; 
    // prints 1
  std::cout << ptr1->f() << std::endl; // prints 123

  return 0;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].