зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625138 - Part 2: Replace mozilla::AddLvalueReference with std::add_lvalue_reference. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68356 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
bf1ba829c8
Коммит
48227ef019
|
@ -752,40 +752,6 @@ namespace detail {
|
|||
|
||||
enum Voidness { TIsVoid, TIsNotVoid };
|
||||
|
||||
template <typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid>
|
||||
struct AddLvalueReferenceHelper;
|
||||
|
||||
template <typename T>
|
||||
struct AddLvalueReferenceHelper<T, TIsVoid> {
|
||||
typedef void Type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct AddLvalueReferenceHelper<T, TIsNotVoid> {
|
||||
typedef T& Type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* AddLvalueReference adds an lvalue & reference to T if one isn't already
|
||||
* present. (Note: adding an lvalue reference to an rvalue && reference in
|
||||
* essence replaces the && with a &&, per C+11 reference collapsing rules. For
|
||||
* example, int&& would become int&.)
|
||||
*
|
||||
* The final computed type will only *not* be an lvalue reference if T is void.
|
||||
*
|
||||
* mozilla::AddLvalueReference<int>::Type is int&;
|
||||
* mozilla::AddLvalueRference<volatile int&>::Type is volatile int&;
|
||||
* mozilla::AddLvalueReference<void*>::Type is void*&;
|
||||
* mozilla::AddLvalueReference<void>::Type is void;
|
||||
* mozilla::AddLvalueReference<struct S&&>::Type is struct S&.
|
||||
*/
|
||||
template <typename T>
|
||||
struct AddLvalueReference : detail::AddLvalueReferenceHelper<T> {};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid>
|
||||
struct AddRvalueReferenceHelper;
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ class UniquePtr {
|
|||
return *this;
|
||||
}
|
||||
|
||||
typename AddLvalueReference<T>::Type operator*() const { return *get(); }
|
||||
std::add_lvalue_reference_t<T> operator*() const { return *get(); }
|
||||
Pointer operator->() const {
|
||||
MOZ_ASSERT(get(), "dereferencing a UniquePtr containing nullptr");
|
||||
return get();
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
test(type, __VA_ARGS__) test(const type, __VA_ARGS__) \
|
||||
test(volatile type, __VA_ARGS__) test(const volatile type, __VA_ARGS__)
|
||||
|
||||
using mozilla::AddLvalueReference;
|
||||
using mozilla::AddPointer;
|
||||
using mozilla::AddRvalueReference;
|
||||
using mozilla::Decay;
|
||||
|
@ -410,18 +409,6 @@ static void TestIsConvertible() {
|
|||
// "C doesn't convert to A (private inheritance)");
|
||||
}
|
||||
|
||||
static_assert(IsSame<AddLvalueReference<int>::Type, int&>::value,
|
||||
"not adding & to int correctly");
|
||||
static_assert(
|
||||
IsSame<AddLvalueReference<volatile int&>::Type, volatile int&>::value,
|
||||
"not adding & to volatile int& correctly");
|
||||
static_assert(IsSame<AddLvalueReference<void*>::Type, void*&>::value,
|
||||
"not adding & to void* correctly");
|
||||
static_assert(IsSame<AddLvalueReference<void>::Type, void>::value,
|
||||
"void shouldn't be transformed by AddLvalueReference");
|
||||
static_assert(IsSame<AddLvalueReference<struct S1&&>::Type, struct S1&>::value,
|
||||
"not reference-collapsing struct S1&& & to struct S1& correctly");
|
||||
|
||||
static_assert(IsSame<AddRvalueReference<int>::Type, int&&>::value,
|
||||
"not adding && to int correctly");
|
||||
static_assert(
|
||||
|
|
Загрузка…
Ссылка в новой задаче