Say I want to make 2 versions of a class - a thread safe version which will use lock guards on all mutating operations, and a 'thread dangerous' one which won't and will presumably run faster in a single-threaded client.
A bit like this:
#include <type_traits>
#include <mutex>
template <bool THREADSAFE>
class wibble {
private:
typename std::enable_if<THREADSAFE, std::mutex>::type mtx_;
};
wibble<true> threadsafe; // ok
wibble<false> thread_dangerous; // compiler error
Thanks!