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.
std::array<T,N>::at is evaluated in a constexpr context, as the throw that at does is not constexpr.How can this overload of STL container accessors work with non-constexpr parameters?
Declaring a function constexpr means that if its called with constant expressions for all its arguments, then the result is also a constant expression.
It can still be called with non-constant arguments; you just can't use the result as a constant expression.
What are classical use cases of this overload?
Getting a compile-time constant out of a suitable container, for example:
constexpr std::array<int,5> values {{2,3,5,7,11}};
template <int n> void do_stuff(); // needs a compile-time constant
do_stuff<values.at(3)>(); // provide a compile-time constant