1#ifndef MSTL_CORE_EXCEPTION_EXCEPTION_PTR_HPP__
2#define MSTL_CORE_EXCEPTION_EXCEPTION_PTR_HPP__
44 virtual const std::type_info&
type() const noexcept = 0;
85 MSTL_ALWAYS_INLINE
void rethrow()
const override {
93 MSTL_ALWAYS_INLINE
const std::type_info&
type() const noexcept
override {
159 explicit exception_ptr(ecb* cb) noexcept : ecb_(cb) {}
161 template <
typename Ex>
168 template <typename Ex>
188 if (ecb_) ecb_->add_ref();
199 other.ecb_ =
nullptr;
218 exception_ptr& operator =(
const exception_ptr& other)
noexcept {
219 if (
this != &other) {
220 exception_ptr temp(other);
231 exception_ptr& operator =(exception_ptr&& other)
noexcept {
232 if (
this != &other) {
243 void swap(exception_ptr& other)
noexcept {
253 explicit operator bool() const noexcept {
254 return ecb_ !=
nullptr;
265 return ecb_ == rhs.ecb_;
274 return !(*
this == rhs);
282 return !
static_cast<bool>(*this);
297 return static_cast<bool>(*this);
304 return static_cast<bool>(ptr);
314 if (!ecb_ || !ecb_->wrapper) {
317 return ecb_->wrapper->type();
331template <
typename Ex>
336 exception_ptr result;
337 result.ecb_ = control_block.
release();
340 return exception_ptr();
MSTL_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
atomic< int > atomic_int
整型原子类型
decltype(nullptr) nullptr_t
空指针类型
exception_ptr(exception_ptr &&other) noexcept
移动构造函数
typed_exception_wrapper(const Ex &ex)
拷贝构造函数
exception_ptr(const exception_ptr &other) noexcept
拷贝构造函数
typed_exception_wrapper(Ex &&ex) noexcept
移动构造函数
virtual void rethrow() const =0
重新抛出异常
~exception_ptr() noexcept
析构函数
virtual unique_ptr< exception_wrapper > clone() const =0
克隆异常包装器
MSTL_ALWAYS_INLINE const std::type_info & type() const noexcept override
获取异常类型信息
MSTL_ALWAYS_INLINE void release() noexcept
减少引用计数
MSTL_ALWAYS_INLINE void rethrow() const override
重新抛出异常
virtual const std::type_info & type() const noexcept=0
获取异常类型信息
unique_ptr< exception_wrapper > wrapper
异常包装器
friend exception_ptr MSTL_API current_exception() noexcept
获取当前异常
exception_ptr make_exception_ptr(Ex ex) noexcept
创建异常指针
MSTL_ALWAYS_INLINE void add_ref() noexcept
增加引用计数
friend void MSTL_API rethrow_exception(const exception_ptr &)
重新抛出异常
MSTL_NODISCARD const std::type_info & exception_type() const noexcept
获取异常类型信息
ecb(unique_ptr< exception_wrapper > wrapper)
构造函数
friend bool operator!=(nullptr_t, const exception_ptr &ptr) noexcept
空指针与异常指针比较不等
void swap(exception_ptr &other) noexcept
交换两个异常指针
MSTL_ALWAYS_INLINE unique_ptr< exception_wrapper > clone() const override
克隆异常包装器
bool operator!=(const function< Res(Args...)> &f, nullptr_t null) noexcept
不等于空指针比较
bool operator==(const function< Res(Args...)> &f, nullptr_t null) noexcept
等于空指针比较
MSTL_INLINE17 constexpr auto memory_order_acq_rel
获取-释放内存顺序常量
MSTL_INLINE17 constexpr auto memory_order_relaxed
宽松内存顺序常量
MSTL_INLINE17 constexpr auto memory_order_acquire
获取内存顺序常量
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result)
移动范围元素
void swap()=delete
删除无参数的swap重载
MSTL_CONSTEXPR20 unique_ptr< T > make_unique(Args &&... args)
创建unique_ptr