One of the nicer features of Rust is explicitly showing whether parameters are mutable, non-mutable, or moved from the caller's site:
foobar(&mut foo, &bar, baz);
// ^ mutable ^ non-mutable ^ moved (copied if trivial)
In C++ we already have tools to do this:
foobar(std::ref(foo), std::as_const(bar), std::move(baz));
Yet, though std::move
is standard practice, I've never seen std::as_const
being used in a function call.
Is there a reason for this, other than maybe std::as_const
is too verbose? Would adding simpler syntactic sugar for it provide a good new feature that makes C++ more readable?