I have a following code:
#include <thread>
void foo(int& value)
{
// do nothing
}
int main()
{
int value = 42;
std::thread t1([&value]{ foo(value); });
std::thread t2([&value]{ value = 100500; });
t1.join();
t2.join();
return 0;
}
Common sense tells there is no data race here, as passing value by reference "must"(???) be thread-safe, but I could not verify it based on cppreference or standard draft N4950.
- How can I verify there is no data race based on cppreference or standard?
- Is passing value by reference thread-safe operation?