Skip to content

Commit 13bfe75

Browse files
committed
Bug 1625138 - Part 40: Replace remaining mozilla::IsSame with std::is_same. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68560 --HG-- extra : moz-landing-system : lando
1 parent 62ab594 commit 13bfe75

File tree

6 files changed

+28
-46
lines changed

6 files changed

+28
-46
lines changed

layout/generic/nsQueryFrame.h

+17-19
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,22 @@
2525
#define NS_QUERYFRAME_HEAD(class) \
2626
void* class ::QueryFrame(FrameIID id) const { \
2727
switch (id) {
28-
#define NS_QUERYFRAME_ENTRY(class) \
29-
case class ::kFrameIID: { \
30-
static_assert( \
31-
mozilla::IsSame<class, class ::Has_NS_DECL_QUERYFRAME_TARGET>::value, \
32-
#class " must declare itself as a queryframe target"); \
33-
return const_cast<class*>(static_cast<const class*>(this)); \
28+
#define NS_QUERYFRAME_ENTRY(class) \
29+
case class ::kFrameIID: { \
30+
static_assert( \
31+
std::is_same_v<class, class ::Has_NS_DECL_QUERYFRAME_TARGET>, \
32+
#class " must declare itself as a queryframe target"); \
33+
return const_cast<class*>(static_cast<const class*>(this)); \
3434
}
3535

36-
#define NS_QUERYFRAME_ENTRY_CONDITIONAL(class, condition) \
37-
case class ::kFrameIID: \
38-
if (condition) { \
39-
static_assert( \
40-
mozilla::IsSame<class, \
41-
class ::Has_NS_DECL_QUERYFRAME_TARGET>::value, \
42-
#class " must declare itself as a queryframe target"); \
43-
return const_cast<class*>(static_cast<const class*>(this)); \
44-
} \
36+
#define NS_QUERYFRAME_ENTRY_CONDITIONAL(class, condition) \
37+
case class ::kFrameIID: \
38+
if (condition) { \
39+
static_assert( \
40+
std::is_same_v<class, class ::Has_NS_DECL_QUERYFRAME_TARGET>, \
41+
#class " must declare itself as a queryframe target"); \
42+
return const_cast<class*>(static_cast<const class*>(this)); \
43+
} \
4544
break;
4645

4746
#define NS_QUERYFRAME_TAIL_INHERITING(class) \
@@ -99,10 +98,9 @@ class do_QueryFrameHelper {
9998

10099
template <class Dest>
101100
operator Dest*() {
102-
static_assert(
103-
mozilla::IsSame<std::remove_const_t<Dest>,
104-
typename Dest::Has_NS_DECL_QUERYFRAME_TARGET>::value,
105-
"Dest must declare itself as a queryframe target");
101+
static_assert(std::is_same_v<std::remove_const_t<Dest>,
102+
typename Dest::Has_NS_DECL_QUERYFRAME_TARGET>,
103+
"Dest must declare itself as a queryframe target");
106104
if (!mRawPtr) {
107105
return nullptr;
108106
}

mfbt/TypeTraits.h

-20
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,6 @@ struct IsDestructibleImpl : public DoIsDestructibleImpl {
102102
template <typename T>
103103
struct IsDestructible : public detail::IsDestructibleImpl<T>::Type {};
104104

105-
/* 20.9.5 Type property queries [meta.unary.prop.query] */
106-
107-
/* 20.9.6 Relationships between types [meta.rel] */
108-
109-
/**
110-
* IsSame tests whether two types are the same type.
111-
*
112-
* mozilla::IsSame<int, int>::value is true;
113-
* mozilla::IsSame<int*, int*>::value is true;
114-
* mozilla::IsSame<int, unsigned int>::value is false;
115-
* mozilla::IsSame<void, void>::value is true;
116-
* mozilla::IsSame<const int, int>::value is false;
117-
* mozilla::IsSame<struct S, struct S>::value is true.
118-
*/
119-
template <typename T, typename U>
120-
struct IsSame : std::false_type {};
121-
122-
template <typename T>
123-
struct IsSame<T, T> : std::true_type {};
124-
125105
} /* namespace mozilla */
126106

127107
#endif /* mozilla_TypeTraits_h */

mfbt/tests/TestTypeTraits.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
55
* You can obtain one at http://mozilla.org/MPL/2.0/. */
66

7+
#include <type_traits>
8+
79
#include "mozilla/Assertions.h"
810
#include "mozilla/TypeTraits.h"
911

1012
using mozilla::IsDestructible;
11-
using mozilla::IsSame;
1213

1314
class PublicDestructible {
1415
public:
@@ -35,9 +36,9 @@ static_assert(IsDestructible<TrivialDestructible>::value,
3536
* actual type sizes seen at compile time.
3637
*/
3738
#if defined(ANDROID) && !defined(__LP64__)
38-
static_assert(mozilla::IsSame<int, intptr_t>::value,
39+
static_assert(std::is_same_v<int, intptr_t>,
3940
"emulated PRI[di]PTR definitions will be wrong");
40-
static_assert(mozilla::IsSame<unsigned int, uintptr_t>::value,
41+
static_assert(std::is_same_v<unsigned int, uintptr_t>,
4142
"emulated PRI[ouxX]PTR definitions will be wrong");
4243
#endif
4344

mozglue/baseprofiler/core/ProfileBufferEntry.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# include "mozilla/StackWalk.h"
2020

2121
# include <ostream>
22+
# include <type_traits>
2223

2324
namespace mozilla {
2425
namespace baseprofiler {
@@ -152,7 +153,7 @@ class MOZ_RAII AutoArraySchemaWriter {
152153

153154
template <typename T>
154155
void IntElement(uint32_t aIndex, T aValue) {
155-
static_assert(!IsSame<T, uint64_t>::value,
156+
static_assert(!std::is_same_v<T, uint64_t>,
156157
"Narrowing uint64 -> int64 conversion not allowed");
157158
FillUpTo(aIndex);
158159
mJSONWriter.IntElement(static_cast<int64_t>(aValue));

tools/profiler/core/ProfileBufferEntry.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "ProfilerCodeAddressService.h"
2121

2222
#include <ostream>
23+
#include <type_traits>
2324

2425
using namespace mozilla;
2526

@@ -161,7 +162,7 @@ class MOZ_RAII AutoArraySchemaWriter {
161162

162163
template <typename T>
163164
void IntElement(uint32_t aIndex, T aValue) {
164-
static_assert(!IsSame<T, uint64_t>::value,
165+
static_assert(!std::is_same_v<T, uint64_t>,
165166
"Narrowing uint64 -> int64 conversion not allowed");
166167
FillUpTo(aIndex);
167168
mJSONWriter.IntElement(static_cast<int64_t>(aValue));

tools/profiler/core/platform.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#include <fstream>
8585
#include <ostream>
8686
#include <sstream>
87+
#include <type_traits>
8788

8889
#ifdef MOZ_TASK_TRACER
8990
# include "GeckoTaskTracer.h"
@@ -2790,8 +2791,8 @@ class SamplerThread {
27902791
// It may be tempting for a future maintainer to change aCallbacks into an
27912792
// rvalue reference; this will remind them not to do that!
27922793
static_assert(
2793-
IsSame<decltype(aCallbacks),
2794-
UniquePtr<PostSamplingCallbackListItem>>::value,
2794+
std::is_same_v<decltype(aCallbacks),
2795+
UniquePtr<PostSamplingCallbackListItem>>,
27952796
"We need to capture the list by-value, to implicitly destroy it");
27962797
}
27972798

0 commit comments

Comments
 (0)