return *this;
}
- bool is_valid()
+ bool is_valid() const
{
return status_ != ResultStatus::invalid;
}
};
template<>
-class Result<void> : public Result<nullptr_t>
+class Result<void> : public Result<std::nullptr_t>
{
public:
void set_value()
}
void get()
{
- Result<nullptr_t>::get();
+ Result<std::nullptr_t>::get();
}
};
}
};
-/** Fulfill a promise by executing a given code */
+/** Execute some code and set a promise or result accordingly
+ *
+ * We might need this when working with generic code because
+ * the trivial implementation does not work with void (before C++1z).
+ *
+ * @param code What we want to do
+ * @param promise Where to want to store the result
+ */
template<class R, class F>
auto fulfillPromise(R& promise, F&& code)
-> decltype(promise.set_value(code()))
}
}
-/** Fulfill a promise by executing a given code
- *
- * This is a special version for `std::promise<void>` because the default
- * version does not compile in this case.
- */
template<class P, class F>
auto fulfillPromise(P& promise, F&& code)
-> decltype(promise.set_value())