命名空间
变体
操作

std::tx_exception

来自 cppreference.cn
< cpp‎ | error
定义于头文件 <stdexcept>
template< class T >
class tx_exception : public std::runtime_error;
(TM TS)

定义了一种异常类型,可用于取消和回滚由关键字 atomic_cancel 发起的原子事务。

如果 T 不是 TriviallyCopyable,则特化 std::tx_exception<T> 的程序是非良构的。

内容

[编辑] 成员函数

std::tx_exception::tx_exception

explicit tx_exception( T value ) transaction_safe;
(1) (TM TS)
tx_exception( T value, const std::string& what_arg ) transaction_safe;
(2) (TM TS)
tx_exception( T value, const char* what_arg ) transaction_safe;
(3) (TM TS)
tx_exception( const tx_exception& other ) transaction_safe noexcept;
(4) (TM TS)
1-3) 构造异常对象,其中 what_arg 作为可通过 what() 访问的解释性字符串,value 作为可通过 get() 访问的对象。
4) 复制构造函数。如果 *thisother 都具有动态类型 std::tx_exception<T>,则 std::strcmp(what(), other.what()) == 0

参数

value - 负载对象
what_arg - 解释性字符串
other - 要复制的另一个异常对象

异常

1-3) 可能抛出实现定义的异常。

std::tx_exception::operator=

tx_exception& operator=( const tx_exception& other ) transaction_safe noexcept;
(TM TS)

将内容赋值为 other 的内容。如果 *thisother 都具有动态类型 std::tx_exception<T>,则赋值后 std::strcmp(what(), other.what()) == 0

参数

other - 要赋值的另一个异常对象

返回值

*this

std::tx_exception::get

T get() const transaction_safe;
(TM TS)

返回异常对象持有的负载对象。

异常

可能抛出实现定义的异常。

std::tx_exception::what

virtual const char* what() const transaction_safe_dynamic noexcept;
(TM TS)

返回解释性字符串。

参数

(无)

返回值

指向包含解释性信息的空终止字符串的指针。

继承自 std::runtime_error


继承自 std::exception

成员函数

销毁异常对象
(virtual public member function of std::exception) [编辑]
[虚函数]
返回解释性字符串
(virtual public member function of std::exception) [编辑]