All Uninitialized-Memory Helpers

All Uninitialized-Memory Helpers

A compact index of raw-storage construction, destruction, and uninitialized algorithms used in low-level library code.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

All Uninitialized-Memory Helpers

Construction into raw storage

Destruction helpers

Allocation-adjacent helpers

Practical rules

Small worked example

#include <memory>
#include <new>

int main() {
	alignas(int) unsigned char storage[sizeof(int)];
	int* value = std::construct_at(reinterpret_cast<int*>(storage), 42);
	int result = *value;
	std::destroy_at(value);
	return result;
}

This is the core raw-storage pattern: create an object in already allocated storage, use it, then destroy it explicitly. That is useful in container internals, allocator-backed buffers, and other low-level code that separates allocation from construction.

Decision guide

Example in practice

#include <memory>

int main() {
    auto owner = std::make_unique<int>(42);
    auto shared = std::make_shared<int>(*owner);
    owner.reset();
    return *shared;
}