Concurrently using std::regex, defined behaviour?

后端 未结 1 1753
青春惊慌失措
青春惊慌失措 2021-02-19 06:27

Is it possible to use a std::regex object in multiple threads all using std::sregex_iterator, std::regex_match, etc.?

<
相关标签:
1条回答
  • 2021-02-19 06:54

    Yes, a const std::regex is thread-safe. Actually any const method in the standard library is thread-safe, see:

    §17.6.5.9/3. A C++ standard library function shall not directly or indirectly modify objects (1.10) accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function’s non-const arguments, including this.

    0 讨论(0)
提交回复
热议问题