Is it possible to create (possibly const
) std::set
that would be filled with elements at compile time?
I am wondering about std::set
/std::unordered_set
specifically, not a set of templated functions that would emulate behaviour of a set.
Is it possible to create (possibly const
) std::set
that would be filled with elements at compile time?
I am wondering about std::set
/std::unordered_set
specifically, not a set of templated functions that would emulate behaviour of a set.
No.
std::set
and std::unordered_set
were designed as runtime containers, they use allocators and more importantly none of their constructor is marked as constexpr
(even the ones taking an std::initializer_list
), which means you can never construct one at compile time.
© 2022 - 2024 — McMap. All rights reserved.