I suppose I'm a bit confused as to how exactly optional values are stored. When constructing a class or struct that contains std::optional<T>
members, will these members be stored contiguously in memory or does optional allocate dynamically? For example, would the below struct be one contiguous block of memory?
struct Material
{
std::string name;
std::optional<size_t> albedo;
std::optional<size_t> normal;
std::optional<size_t> metalness;
std::optional<size_t> roughness;
std::optional<size_t> ao; // ambient occlusion
bool hasAlphaChannel = false;
};