Backed out changeset 5200dd8a0de5 (bug 1645328) for cppunit assertion failures at Maybe.h. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2020-06-12 20:12:37 +03:00
parent 16c32eb29a
commit bff7221969
2 changed files with 4 additions and 33 deletions

View File

@ -265,11 +265,6 @@ struct MaybeStorage<T, false> {
explicit MaybeStorage(const T& aVal) : mStorage{aVal}, mIsSome{true} {}
explicit MaybeStorage(T&& aVal) : mStorage{std::move(aVal)}, mIsSome{true} {}
template <typename... Args>
explicit MaybeStorage(Args&&... aArgs) : mIsSome{true} {
::new (KnownNotNull, &mStorage.val) T(std::forward<Args>(aArgs)...);
}
// Copy and move operations are no-ops, since copying is moving is implemented
// by Maybe_CopyMove_Enabler.
@ -304,14 +299,6 @@ struct MaybeStorage<T, true> {
: mStorage{aVal}, mIsSome{true} {}
constexpr explicit MaybeStorage(T&& aVal)
: mStorage{std::move(aVal)}, mIsSome{true} {}
// XXX This should be constexpr, but then we can't use placement new.
// Delegating this to a Union constructor with the same signature doesn't
// build out of the box.
template <typename... Args>
explicit MaybeStorage(Args&&... aArgs) : mIsSome{true} {
::new (KnownNotNull, &mStorage.val) T(std::forward<Args>(aArgs)...);
}
};
} // namespace detail
@ -363,6 +350,9 @@ constexpr Maybe<U> Some(T&& aValue);
* Boost. The most important differences between Maybe and std::optional are:
*
* - std::optional<T> may be compared with T. We deliberately forbid that.
* - std::optional allows in-place construction without a separate call to
* |emplace()| by using a dummy |in_place_t| value to tag the appropriate
* constructor.
* - std::optional has |valueOr()|, equivalent to Maybe's |valueOr()|, but
* lacks corresponding methods for |refOr()| and |ptrOr()|.
* - std::optional lacks |map()| and |apply()|, making it less suitable for
@ -399,10 +389,6 @@ class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Maybe
MOZ_ALLOW_TEMPORARY MOZ_IMPLICIT constexpr Maybe(Nothing) : Maybe{} {}
template <typename... Args>
constexpr explicit Maybe(std::in_place_t, Args&&... aArgs)
: detail::MaybeStorage<T>(std::forward<Args>(aArgs)...) {}
/**
* Maybe<T> can be copy-constructed from a Maybe<U> if T is constructible from
* a const U&.

View File

@ -156,7 +156,7 @@ struct UncopyableUnmovableValue {
~UncopyableUnmovableValue() { --sUndestroyedObjects; }
Status GetStatus() const { return mStatus; }
Status GetStatus() { return mStatus; }
private:
UncopyableUnmovableValue(const UncopyableUnmovableValue& aOther) = delete;
@ -261,14 +261,6 @@ static bool TestBasicFeatures() {
mayValue.reset();
MOZ_RELEASE_ASSERT(!mayValue);
{
// Check that Maybe(std::in_place, T1) calls the correct constructor.
const auto mayValueConstructed = Maybe<BasicValue>(std::in_place, 1);
MOZ_RELEASE_ASSERT(mayValueConstructed);
MOZ_RELEASE_ASSERT(mayValueConstructed->GetStatus() == eWasConstructed);
MOZ_RELEASE_ASSERT(mayValueConstructed->GetTag() == 1);
}
// Check that Some() and Nothing() work.
mayValue = Some(BasicValue(2));
MOZ_RELEASE_ASSERT(mayValue);
@ -505,13 +497,6 @@ static bool TestCopyAndMove() {
MOZ_RELEASE_ASSERT(0 == sUndestroyedObjects);
{ // Check that types that support neither moves or copies work.
{
const auto mayUncopyableUnmovableValueConstructed =
Maybe<UncopyableUnmovableValue>{std::in_place};
MOZ_RELEASE_ASSERT(mayUncopyableUnmovableValueConstructed->GetStatus() ==
eWasDefaultConstructed);
}
Maybe<UncopyableUnmovableValue> mayUncopyableUnmovableValue;
mayUncopyableUnmovableValue.emplace();
MOZ_RELEASE_ASSERT(mayUncopyableUnmovableValue->GetStatus() ==