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
- 32-bit Architectures: 32-bit pointers, 4GB address space
- x86, ARMv6/v7, 32-bit MIPS/PowerPC/RISC-V/SPARC
- 64-bit Architectures: 64-bit pointers, large address space
- x86_64, ARM64, 64-bit MIPS/PowerPC/RISC-V/SPARC
Applications
- Memory Management: Size calculations, pointer arithmetic
- Serialization: Platform-aware data format selection
- Performance: Cache efficiency, data structure layout
- 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
if constexpr (ptr_size == 64) {
using hash_type = std::uint64_t;
} else {
using hash_type = std::uint32_t;
}
- Since
- 1.0.0