зеркало из https://github.com/mozilla/gecko-dev.git
Bug 891177 - Add an explanatory comment by the const_cast<> in the Move(const T&) overload. r=luke
--HG-- extra : rebase_source : 37a91bf2bdfe2b2f96ddebf276ad532d4419c42b
This commit is contained in:
Родитель
fa373bf8d8
Коммит
8a8e1ffd26
14
mfbt/Move.h
14
mfbt/Move.h
|
@ -133,6 +133,20 @@ template<typename T>
|
|||
inline MoveRef<T>
|
||||
Move(const T& t)
|
||||
{
|
||||
// With some versions of gcc, for a class C, there's an (incorrect) ambiguity
|
||||
// between the C(const C&) constructor and the default C(C&&) C++11 move
|
||||
// constructor, when the constructor is called with a const C& argument.
|
||||
//
|
||||
// This ambiguity manifests with the Move implementation above when Move is
|
||||
// passed const U& for some class U. Calling Move(const U&) returns a
|
||||
// MoveRef<const U&>, which is then commonly passed to the U constructor,
|
||||
// triggering an implicit conversion to const U&. gcc doesn't know whether to
|
||||
// call U(const U&) or U(U&&), so it wrongly reports a compile error.
|
||||
//
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50442 has since been fixed, so
|
||||
// this is no longer an issue for up-to-date compilers. But there's no harm
|
||||
// in keeping it around for older compilers, so we might as well. See also
|
||||
// bug 686280.
|
||||
return MoveRef<T>(const_cast<T&>(t));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче