mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 975246 - Part1 - Implement operator->* in nsRefPtr. r=nfroyd, r=gerald
This commit is contained in:
parent
9e348de2d0
commit
43f57cf317
@ -251,19 +251,31 @@ public:
|
||||
return get();
|
||||
}
|
||||
|
||||
// This operator is needed for gcc <= 4.0.* and for Sun Studio; it
|
||||
// causes internal compiler errors for some MSVC versions. (It's not
|
||||
// clear to me whether it should be needed.)
|
||||
#ifndef _MSC_VER
|
||||
template <class U, class V>
|
||||
U&
|
||||
operator->*(U V::* aMember)
|
||||
template <typename R, typename... Args>
|
||||
class Proxy
|
||||
{
|
||||
typedef R (T::*member_function)(Args...);
|
||||
T* mRawPtr;
|
||||
member_function mFunction;
|
||||
public:
|
||||
Proxy(T* aRawPtr, member_function aFunction)
|
||||
: mRawPtr(aRawPtr),
|
||||
mFunction(aFunction)
|
||||
{
|
||||
}
|
||||
R operator()(Args... aArgs)
|
||||
{
|
||||
return ((*mRawPtr).*mFunction)(mozilla::Forward<Args>(aArgs)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
Proxy<R, Args...> operator->*(R (T::*aFptr)(Args...)) const
|
||||
{
|
||||
MOZ_ASSERT(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator->*().");
|
||||
return get()->*aMember;
|
||||
return Proxy<R, Args...>(get(), aFptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsRefPtr<T>*
|
||||
get_address()
|
||||
|
Loading…
Reference in New Issue
Block a user