I\'ve been digging around ref-qualifiers a bit, following on a previous question.
Given the code sample below;
#include
#include <
Suppose we have a type with a mutable
state. Then const&&
will both allow us to mutate that state, and indicate that such mutation is safe.
struct bar;
struct foo {
mutable std::vector state;
operator bar() const&;
operator bar() const&&;
};
const
is not absolute.
Barring mutable state, it is not safe to cast away const
in a const&&
method in order to extract state, because extracting state in this way from an actual const
object is undefined behavior.