constexpr const_reference at( size_type pos ) const;
How can this overload of STL container accessors work with non-constexpr parameters? What are classical use cases of this overload?
There is no such thing as constexpr parameters in a function declaration. A constexpr function call can only be evaluated at compile time if and only if all parameters involved in that function call are constant expressions.
That being said, the only case where a constexpr function must be evaluated at compile time is when it is used to calculate a template parameter.
At least one use case for the example you give, is for std::array::at.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With