I need to create unique_lock or shared lock based on a parameter in my function. I couldn't define properly in the scope of function. So I need to do something like this.
function (bool check) { lock; if (check) { lock = std::unique_lock<std::shared_mutex>(mutex); } else { lock = std::shared_lock<std::shared_mutex>(mutex); } lock.lock(); doTask....
doTask....a function and then call that function in each branch