diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -318,9 +318,6 @@ template constexpr T value_or(U &&alt) const & { return has_value() ? value() : std::forward(alt); } - template constexpr T getValueOr(U &&alt) const & { - return has_value() ? value() : std::forward(alt); - } /// Apply a function to the value if present; otherwise return None. template @@ -337,9 +334,6 @@ template T value_or(U &&alt) && { return has_value() ? std::move(value()) : std::forward(alt); } - template T getValueOr(U &&alt) && { - return has_value() ? std::move(value()) : std::forward(alt); - } /// Apply a function to the value if present; otherwise return None. template diff --git a/llvm/unittests/ADT/OptionalTest.cpp b/llvm/unittests/ADT/OptionalTest.cpp --- a/llvm/unittests/ADT/OptionalTest.cpp +++ b/llvm/unittests/ADT/OptionalTest.cpp @@ -210,11 +210,9 @@ TEST(OptionalTest, GetValueOr) { Optional A; EXPECT_EQ(42, A.value_or(42)); - EXPECT_EQ(42, A.getValueOr(42)); A = 5; EXPECT_EQ(5, A.value_or(42)); - EXPECT_EQ(5, A.getValueOr(42)); } struct MultiArgConstructor { @@ -605,23 +603,6 @@ EXPECT_EQ(2u, MoveOnly::Destructions); } -TEST(OptionalTest, MoveGetValueOr) { - Optional A; - - MoveOnly::ResetCounts(); - EXPECT_EQ(42, std::move(A).getValueOr(MoveOnly(42)).val); - EXPECT_EQ(1u, MoveOnly::MoveConstructions); - EXPECT_EQ(0u, MoveOnly::MoveAssignments); - EXPECT_EQ(2u, MoveOnly::Destructions); - - A = MoveOnly(5); - MoveOnly::ResetCounts(); - EXPECT_EQ(5, std::move(A).getValueOr(MoveOnly(42)).val); - EXPECT_EQ(1u, MoveOnly::MoveConstructions); - EXPECT_EQ(0u, MoveOnly::MoveAssignments); - EXPECT_EQ(2u, MoveOnly::Destructions); -} - struct EqualTo { template static bool apply(const T &X, const U &Y) { return X == Y;