1

I have tried some experiments on c++11 regex using multithread and I think it's not multi thread safe library.

I just can't explain more. Please help me :(

Young Hyun Yoo
  • 598
  • 10
  • 21
  • 3
    And what is your specific problem? – Mat Aug 04 '13 at 05:32
  • Sorry for poor explanation. I use while(std::regex(s,m,e){} code and I get deadlock. – Young Hyun Yoo Aug 04 '13 at 05:34
  • @Young: That doesn't make sense -- your expression in the `while` returns a `std::regex`, not `bool`. That shouldn't compile. Please post the actual code with which you're having problems and perhaps we can better help. – Billy ONeal Aug 04 '13 at 05:35
  • 1
    Please add a Short, Self Contained, Correct/Compilable, Example: http://sscce.org/ – dalle Aug 04 '13 at 07:03

1 Answers1

3

Calling const member functions of a regex is a thread safe operation. Calling non-const member functions is not guaranteed to be thread safe.

Considering the only way to make things like that thread safe would be to enter a lock, if you want that to be thread safe, then just protect the regex with a lock.

Billy ONeal
  • 104,103
  • 58
  • 317
  • 552