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
#define SLED_FUTURES_FUTURE_H
#include <exception>
#pragma once
#include "sled/exec/detail/invoke_result.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 {
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");

View File

@ -10,18 +10,18 @@ namespace sled {
template<typename T, typename FailureT>
class Future;
template<typename T, typename FailureT>
class Promise {
template<typename T, typename FailureT = std::exception>
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<FailureT, void>::value,
"Promise<_, void> is not allowed. Use Promise<_, bool> instead");
public:
using Value = T;
Promise() noexcept = default;
Promise(const Promise &) noexcept = default;
Promise() = default;
Promise(const Promise &) = default;
Promise(Promise &&) noexcept = default;
Promise &operator=(const Promise &) noexcept = default;
Promise &operator=(const Promise &) = default;
Promise &operator=(Promise &&) noexcept = default;
~Promise() = default;