Given the std::tuple
,
using Tuple1 = std::tuple<Foo1*, Bar1*, std::shared_ptr<std::mutex>>;
using Tuple2 = std::tuple<Foo2*, Bar2*, std::shared_ptr<std::mutex>>;
std::tuple<Tuple1, Tuple2> tuple;
And the function,
void baz()
{
auto tup = std::get<0>(tuple);
std::lock_guard<std::mutex> lk(*std::get<2>(tup));
// Do something with std::get<0>(tup) and std::get<1>(tup)
}
According to this question on SO accessing a std::tuple
is not inherently thread-safe, but what about in the case of the example code? Is it possible for undefined/strange things to happen?
This is assuming FooN
& BarN
are only ever accessed after the lock.