The C++ implementation provides high-performance, type-safe access to shared memory data structures using modern C++23 features.
- Template-based: Compile-time type safety and optimization
- Zero-overhead: No runtime type checking in hot paths
- RAII: Automatic resource management
- Lock-free: Atomic operations for concurrent data structures
- Header-only: Easy integration
cmake -B build .
cmake --build buildctest --test-dir build#include <zeroipc/memory.h>
#include <zeroipc/array.h>
int main() {
// Create or open shared memory
zeroipc::Memory mem("/sensor_data", 10 * 1024 * 1024); // 10MB
// Create array with compile-time type
zeroipc::Array<float> readings(mem, "temperature", 1000);
// Direct access
readings[0] = 23.5f;
// STL compatibility
std::fill(readings.begin(), readings.end(), 0.0f);
return 0;
}Memory(const std::string& name, size_t size = 0, size_t max_entries = 64)name: Shared memory identifier (e.g., "/myshm")size: Size in bytes (0 to open existing)max_entries: Maximum table entries
template<typename T>
Array(Memory& memory, std::string_view name, size_t capacity = 0)T: Element type (must be trivially copyable)memory: Memory instancename: Array identifiercapacity: Number of elements (0 to open existing)
- C++23 compatible compiler
- POSIX shared memory support
- CMake 3.20+
- Fixed critical lock-free bugs: Queue head/tail confusion, Stack ABA vulnerability, proper fence placement
- All 9 synchronization primitives (Mutex, RWLock, Monitor, Event, Semaphore, Barrier, Latch, Once, Signal)
- 4 codata structures (Future, Lazy, Stream, Channel)
The C++ implementation prioritizes:
- Type safety through templates
- Performance via compile-time optimization
- Modern C++ idioms and features
- Zero-copy access patterns