25 #include <type_traits> 28 #include <glog/logging.h> 30 using std::shared_ptr;
31 using std::unique_ptr;
48 template <
class V,
class E>
49 std::ostream& operator<<(std::ostream& os, const Expected<V, E>& e) {
51 os <<
"Expected(" << e.value() <<
')';
53 os <<
"Unexpected(" << e.error() <<
')';
79 maybeString =
"hello";
154 return o1.
s_ == o2.
s_;
168 const auto& exc = ex;
173 EXPECT_EQ(
"world", exc.value_or(
"world"));
185 std::unique_ptr<int> dflt(
new int(42));
233 ex = std::make_unique<int>(6);
236 ex = std::make_unique<int>(7);
259 ex.emplace(
new int(5));
280 Expected<shared_ptr<int>,
int> moved(
std::move(ex));
282 moved.emplace(
new int(6));
290 std::vector<Expected<int, E>> vect{
297 std::vector<Expected<int, E>> expected{
304 std::sort(vect.begin(), vect.end());
453 if (mbool && mshort && mstr && mint) {
454 if (*mbool && *mshort && *mstr && *mint) {
488 auto exStr = makeExpected<E>(
s);
497 auto exStr2 = makeExpected<E>(s2);
506 auto exStr3 = makeExpected<E>(s3);
513 unique_ptr<int> pInt(
new int(3));
514 auto exIntPtr = makeExpected<E>(
std::move(pInt));
522 a =
static_cast<decltype(a)&
>(
a);
526 b =
static_cast<decltype(b)&&
>(
b);
527 ASSERT_TRUE(b.hasValue() && b.value() ==
"23333333");
535 return ex_.hasValue();
596 EXPECT_TRUE((std::is_nothrow_default_constructible<
633 #pragma GCC diagnostic push 634 #pragma GCC diagnostic ignored "-Wpragmas" 639 e =
static_cast<decltype(e)&
>(e);
640 e =
static_cast<decltype(e)&&
>(e);
644 #pragma GCC diagnostic pop 670 #if (defined(__clang__) && !defined(_LIBCPP_VERSION)) || \ 671 !(defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5) 692 [](std::unique_ptr<int> p) {
return *p; });
701 [](std::unique_ptr<int> p) {
return makeExpected<E>(*p); });
710 [](std::unique_ptr<int>) {});
718 [](std::unique_ptr<int> p) {
return makeExpected<int>(*p); });
728 [](std::unique_ptr<int> p) ->
int {
740 [](std::unique_ptr<int> p) {
return makeExpected<E>(*p); },
741 [](
int i) {
return i == 42 ?
"yes" :
"no"; });
750 [](std::unique_ptr<int>) {
753 [](
int i) {
return i == 42 ?
"yes" :
"no"; });
763 [](std::unique_ptr<int> p) {
return *p; });
770 [](std::unique_ptr<int> p) {
return *p; })),
777 [](std::unique_ptr<int> p) {
return *p; },
778 [](
E) {
return std::runtime_error(
""); })),
785 [](std::unique_ptr<int> p) {
return *p; },
786 [](
E) {
throw std::runtime_error(
""); })),
793 [](std::unique_ptr<int> p) {
return *p; }, [](
E) {})),
constexpr bool hasValue() const noexcept
void swap(Expected &that) noexcept(expected_detail::StrictAllOf< IsNothrowSwappable, Value, Error >::value)
#define EXPECT_THROW(statement, expected_exception)
ExpectingDeleter(int expected_)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
—— Concurrent Priority Queue Implementation ——
in_place_tag in_place(in_place_tag={})
NoSelfAssign & operator=(const NoSelfAssign &that)
requires E e noexcept(noexcept(s.error(std::move(e))))
void operator()(const int *ptr)
Value value_or(U &&dflt) const &
MoveTester & operator=(MoveTester &&other) noexcept
constexpr auto empty(C const &c) -> decltype(c.empty())
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
expected_detail::UnexpectedTag unexpected(expected_detail::UnexpectedTag={})
MoveTester(MoveTester &&other) noexcept
MoveTester(const char *s)
const Error & error() const &
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
std::is_trivially_copyable< T > is_trivially_copyable
const Value & value() const &
#define EXPECT_TRUE(condition)
const Value * get_pointer(const Expected< Value, Error > &ex) noexcept
void swap(exception_wrapper &a, exception_wrapper &b) noexcept
bool operator==(const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
#define EXPECT_NE(val1, val2)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
#define EXPECT_FALSE(condition)
#define ASSERT_TRUE(condition)
NoSelfAssign & operator=(NoSelfAssign &&that)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
std::ostream & operator<<(std::ostream &out, dynamic const &d)