...

/

Performance & Memory Considerations

Performance & Memory Considerations

This module provides a comparison of std::any with std::variant and std::optional evaluating based on efficiency and memory allocations.

std::any looks quite powerful, and you might use it to hold variables of variable types… but you might ask what the price is for such flexibility.

The Main Issue: Extra Dynamic Memory Allocations.

std::variant and std::optional don’t require any extra memory allocations but this is because they know which type (or types) will be ...