TRLC Platform Library  1.0.0
Header-only C++ library for compile-time platform detection and abstraction
Pointer

Gets the pointer size in bits Determines the size of pointers on the target architecture, which indicates the address space size and affects memory management decisions.

Pointer Sizes by Architecture

Applications

Returns
Pointer size in bits (32 or 64)
Note
This function is constexpr and evaluates at compile time
See also
is32BitArchitecture() for boolean 32-bit check
is64BitArchitecture() for boolean 64-bit check
ArchitectureInfo::is32Bit() and ArchitectureInfo::is64Bit()

size-aware code

constexpr int ptr_size = trlc::platform::getPointerSize();
if constexpr (ptr_size == 64) {
// 64-bit optimizations
using hash_type = std::uint64_t;
} else {
// 32-bit compatibility
using hash_type = std::uint32_t;
}
static int getPointerSize()
Since
1.0.0