The Chromium style guide says these are disallowed because of the Google C++ style guide, but the Google C++ style guide doesn't say anything about them, and they're being used within Google's internal code base. (E.g., search for
") && {" lang:c++.)
Once we have MSVC 2015, is there anything else preventing use of ref-qualifiers in Chromium C++?
In the mean-time, could we still opportunistically use ref-qualifiers for non-overloaded member functions that should only be used on rvalues? E.g., in base/compiler_specific.h, something like:
#if defined(COMPILER_MSVC)
#define RVALUE_ONLY /* sad panda */
#else
#define RVALUE_ONLY &&
#endif
Then we could write code like:
class Foo {
public:
Foo();
~Foo();
void Bar() RVALUE_ONLY;
};
and at least usages like:
void f() {
Foo().Bar(); // ok
Foo foo;
std::move(foo).Bar(); // ok
foo.Bar(); // ERROR
}
could be enforced correctly on non-MSVC compilers today.
MSVC would unfortunately not catch the misuse (until we start using 2015), but that's no different than how it doesn't catch misuse of WARN_UNUSED_RESULT functions today.