Merge branch 'master' of code.uocat.com:tqcq/sled
All checks were successful
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 2m2s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m22s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 2m30s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 4m52s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 5m6s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 5m34s

This commit is contained in:
tqcq 2024-04-19 15:43:37 +08:00
commit 4c652abfe6
2 changed files with 11 additions and 10 deletions

View File

@ -1,6 +1,7 @@
#ifndef SLED_FUTURES_FUTURE_H #ifndef SLED_FUTURES_FUTURE_H
#define SLED_FUTURES_FUTURE_H #define SLED_FUTURES_FUTURE_H
#include <exception>
#pragma once #pragma once
#include "sled/exec/detail/invoke_result.h" #include "sled/exec/detail/invoke_result.h"
#include "sled/futures/internal/failure_handling.h" #include "sled/futures/internal/failure_handling.h"
@ -59,7 +60,7 @@ struct FutureData {
// //
template<typename T, typename FailureT> template<typename T, typename FailureT = std::exception>
class Future { class Future {
static_assert(!std::is_same<T, void>::value, "Future<void, _> is not allowed. Use Future<bool, _> instead"); static_assert(!std::is_same<T, void>::value, "Future<void, _> is not allowed. Use Future<bool, _> instead");
static_assert(!std::is_same<FailureT, void>::value, "Future<_, void> is not allowed. Use Future<_, bool> instead"); static_assert(!std::is_same<FailureT, void>::value, "Future<_, void> is not allowed. Use Future<_, bool> instead");

View File

@ -10,20 +10,20 @@ namespace sled {
template<typename T, typename FailureT> template<typename T, typename FailureT>
class Future; class Future;
template<typename T, typename FailureT> template<typename T, typename FailureT = std::exception>
class Promise { class Promise final {
static_assert(!std::is_same<T, void>::value, "Promise<void, _> is not allowed. Use Promise<bool, _> instead"); static_assert(!std::is_same<T, void>::value, "Promise<void, _> is not allowed. Use Promise<bool, _> instead");
static_assert(!std::is_same<FailureT, void>::value, static_assert(!std::is_same<FailureT, void>::value,
"Promise<_, void> is not allowed. Use Promise<_, bool> instead"); "Promise<_, void> is not allowed. Use Promise<_, bool> instead");
public: public:
using Value = T; using Value = T;
Promise() noexcept = default; Promise() = default;
Promise(const Promise &) noexcept = default; Promise(const Promise &) = default;
Promise(Promise &&) noexcept = default; Promise(Promise &&) noexcept = default;
Promise &operator=(const Promise &) noexcept = default; Promise &operator=(const Promise &) = default;
Promise &operator=(Promise &&) noexcept = default; Promise &operator=(Promise &&) noexcept = default;
~Promise() = default; ~Promise() = default;
Future<T, FailureT> GetFuture() const { return future_; }; Future<T, FailureT> GetFuture() const { return future_; };