mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
2e8b8ce3c9
commit
22dc4f4806
14
mfbt/Move.h
14
mfbt/Move.h
@ -133,6 +133,20 @@ template<typename T>
|
|||||||
inline MoveRef<T>
|
inline MoveRef<T>
|
||||||
Move(const T& 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));
|
return MoveRef<T>(const_cast<T&>(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user