зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1331495 - Add an operator<< overload for Maybe. r=froydnj
MozReview-Commit-ID: 8TcYoikeCvR --HG-- extra : rebase_source : 591e3c635ae5521418105e2ad1fc2672143eceeb
This commit is contained in:
Родитель
a2e223b2f8
Коммит
79e41b270d
12
mfbt/Maybe.h
12
mfbt/Maybe.h
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <new> // for placement new
|
||||
#include <ostream>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -452,6 +453,17 @@ public:
|
|||
::new (mStorage.addr()) T(Forward<Args>(aArgs)...);
|
||||
mIsSome = true;
|
||||
}
|
||||
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& aStream, const Maybe<T>& aMaybe)
|
||||
{
|
||||
if (aMaybe) {
|
||||
aStream << aMaybe.ref();
|
||||
} else {
|
||||
aStream << "<Nothing>";
|
||||
}
|
||||
return aStream;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче