I was looking at the API for std::optional<T>
on cppreference. I was curious how value_or
would work. Looking there, it seems there are two overloads:
template< class U >
constexpr T value_or( U&& value ) const&;
template< class U >
T value_or( U&& value ) &&;
What are the const&
and &&
trailing the function declaration? What is the difference between declaring a function as const
and declaring it as const&
?