簡體   English   中英

構造函數后面的宏。 這是什么意思?

[英]Macro behind constructor. What does it mean?

#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++ 標准委員會有一些小組研究並提出了一些實驗特性。 其中之一是事務性 Memory 研究組 (SG5)。 他們的主要工作成果是C++ Extensions for Transactional Memory 的技術規范 您可以閱讀Transactional memory上的簡單版本。

該提案的一部分是transaction_safe function 說明符。 所以你的 function 將是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM