c++ - 构造函数后面的宏。这是什么意思?

标签 c++

#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)。他们的主要工作成果是Technical Specification for C++ Extensions for Transactional Memory 。您可以在 Transactional memory 上阅读简单版本.

该提案的一部分是一个 transaction_safe 函数说明符。所以你的函数是:

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

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

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

// 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

关于c++ - 构造函数后面的宏。这是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62399668/

相关文章:

C++:类型定义和嵌套类问题

c++ - 包括 boost/asio.hpp 抛出错误

c++ - 防止 std::vector 在 push_back 上调整大小

c++ - 构建插件以扩展 Qt 应用程序

c++ - 如何在 C++ 编程中从 wget 创建的套接字中检索 RTT?

c++ - 将 C++ 中的多个参数传递给 MatLab 共享库函数

c++ - 需要一个有效的减法算法模数

c++ - C/C++编译器反馈优化

C++ - 类型的非常量引用的初始化无效

c++ - 是否可以使用 Moz2D 图形 API 在桌面应用程序中绘图?