Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom implementations of std::remove_reference #2395

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions googlemock/include/gmock/gmock-matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1607,9 +1607,8 @@ class PointeeMatcher {
template <typename Pointer>
class Impl : public MatcherInterface<Pointer> {
public:
typedef
typename PointeeOf<typename std::remove_const<GTEST_REMOVE_REFERENCE_(
Pointer)>::type>::type Pointee;
typedef typename PointeeOf<GTEST_REMOVE_REFERENCE_AND_CONST_(Pointer)>::type
Pointee;

explicit Impl(const InnerMatcher& matcher)
: matcher_(MatcherCast<const Pointee&>(matcher)) {}
Expand Down
4 changes: 2 additions & 2 deletions googlemock/include/gmock/gmock-spec-builders.h
Original file line number Diff line number Diff line change
Expand Up @@ -1320,8 +1320,8 @@ class ReferenceOrValueWrapper {

// Provides nondestructive access to the underlying value/reference.
// Always returns a const reference (more precisely,
// const RemoveReference<T>&). The behavior of calling this after
// calling Unwrap on the same object is unspecified.
// const std::add_lvalue_reference<T>::type). The behavior of calling this
// after calling Unwrap on the same object is unspecified.
const T& Peek() const {
return value_;
}
Expand Down
6 changes: 0 additions & 6 deletions googlemock/include/gmock/internal/gmock-internal-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,6 @@ class WithoutMatchers {
// Internal use only: access the singleton instance of WithoutMatchers.
GTEST_API_ WithoutMatchers GetWithoutMatchers();

// Type traits.

// remove_reference<T>::type removes the reference from type T, if any.
template <typename T> struct remove_reference { typedef T type; }; // NOLINT
template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT

// Disable MSVC warnings for infinite recursion, since in this case the
// the recursion is unreachable.
#ifdef _MSC_VER
Expand Down
9 changes: 0 additions & 9 deletions googlemock/test/gmock-internal-utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <memory>
#include <sstream>
#include <string>
#include <type_traits>
#include <vector>

#include "gmock/gmock.h"
Expand Down Expand Up @@ -508,14 +507,6 @@ TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) {

#endif // GTEST_HAS_STREAM_REDIRECTION

TEST(TypeTraitsTest, remove_reference) {
EXPECT_TRUE((std::is_same<char, remove_reference<char&>::type>::value));
EXPECT_TRUE(
(std::is_same<const int, remove_reference<const int&>::type>::value));
EXPECT_TRUE((std::is_same<int, remove_reference<int>::type>::value));
EXPECT_TRUE((std::is_same<double*, remove_reference<double*>::type>::value));
}

#if GTEST_HAS_STREAM_REDIRECTION

// Verifies that Log() behaves correctly for the given verbosity level
Expand Down
15 changes: 1 addition & 14 deletions googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -856,22 +856,9 @@ template <typename T>
struct CompileAssertTypesEqual<T, T> {
};

// Removes the reference from a type if it is a reference type,
// otherwise leaves it unchanged. This is the same as
// tr1::remove_reference, which is not widely available yet.
template <typename T>
struct RemoveReference { typedef T type; }; // NOLINT
template <typename T>
struct RemoveReference<T&> { typedef T type; }; // NOLINT

// A handy wrapper around RemoveReference that works when the argument
// T depends on template parameters.
#define GTEST_REMOVE_REFERENCE_(T) \
typename ::testing::internal::RemoveReference<T>::type

// Turns const U&, U&, const U, and U all into U.
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
typename std::remove_const<GTEST_REMOVE_REFERENCE_(T)>::type
typename std::remove_const<typename std::remove_reference<T>::type>::type

// IsAProtocolMessage<T>::value is a compile-time bool constant that's
// true if T is type proto2::Message or a subclass of it.
Expand Down
25 changes: 0 additions & 25 deletions googletest/test/gtest_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ using testing::internal::OsStackTraceGetterInterface;
using testing::internal::ParseInt32Flag;
using testing::internal::RelationToSourceCopy;
using testing::internal::RelationToSourceReference;
using testing::internal::RemoveReference;
using testing::internal::ShouldRunTestOnShard;
using testing::internal::ShouldShard;
using testing::internal::ShouldUseColor;
Expand Down Expand Up @@ -7110,30 +7109,6 @@ TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {
CompileAssertTypesEqual<int*, int*>();
}

// Tests that RemoveReference does not affect non-reference types.
TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) {
CompileAssertTypesEqual<int, RemoveReference<int>::type>();
CompileAssertTypesEqual<const char, RemoveReference<const char>::type>();
}

// Tests that RemoveReference removes reference from reference types.
TEST(RemoveReferenceTest, RemovesReference) {
CompileAssertTypesEqual<int, RemoveReference<int&>::type>();
CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>();
}

// Tests GTEST_REMOVE_REFERENCE_.

template <typename T1, typename T2>
void TestGTestRemoveReference() {
CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_(T2)>();
}

TEST(RemoveReferenceTest, MacroVersion) {
TestGTestRemoveReference<int, int>();
TestGTestRemoveReference<const char, const char&>();
}

// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.

template <typename T1, typename T2>
Expand Down