构造函数后面的宏.什么意思?

Macro behind constructor. What does it mean?

本文关键字:什么 意思 构造函数      更新时间:2023-10-16
#define _GLIBCXX_TXN_SAFE
class out_of_range : public logic_error 
{
public:
explicit out_of_range(const string& __arg)_GLIBCXX_TXN_SAFE;
};

_GLIBCXX_TXN_SAFE这里是什么意思?

C++标准委员会有一些小组来研究和提出一些实验性特征。其中之一是事务性记忆研究组(SG5(。他们的主要工作成果是事务内存C++扩展的技术规范。可以在事务内存上读取简单版本。

此建议的一部分是transaction_safe函数说明符。所以你的函数将是:

class out_of_range : public logic_error 
{
public:
explicit out_of_range(const string& __arg) transaction_safe;
};

请注意,transaction_safe是一个关键字。

如果满足功能,宏只是有条件地定义此说明符。 例如,从这里获取:

// Conditionally enable annotations for the Transactional Memory TS on C++11.
// Most of the following conditions are due to limitations in the current
// implementation.
#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI            
&& _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L 
&&  !_GLIBCXX_FULLY_DYNAMIC_STRING && __GXX_WEAK__            
&& _GLIBCXX_USE_ALLOCATOR_NEW
#define _GLIBCXX_TXN_SAFE transaction_safe
#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
#else
#define _GLIBCXX_TXN_SAFE
#define _GLIBCXX_TXN_SAFE_DYN
#endif