I have an interface using the pimpl
idiom, however the interface needs to be reentrant. Calling threads do not need to be aware of the locking, however. This is
Using a Pimpl idiom, the mutex should be part of the implementation. This will let you to master when the lock is started.
BTW, why using a unique_lock when a lock_guard will be enough?
I don't see any advantage to make impl public.
std::unique_ptr should be as efficient as a pointer for most of the moderns compilers. Not verified however.
I would forward the const char[N] foo_set not as
template
bool foo_set(const char (&new_val)[N]) { return foo_set(std::string(new_val, N)); }
but like
template
bool foo_set(const char (&new_val)[N]) { return foo_set(N, new_val); }
This avoids the string creation on the header file and let the implementation do whatever is needed.