diff --git a/lib/inc/drogon/IOThreadStorage.h b/lib/inc/drogon/IOThreadStorage.h index ddc0d2d8..78db6f0b 100644 --- a/lib/inc/drogon/IOThreadStorage.h +++ b/lib/inc/drogon/IOThreadStorage.h @@ -57,31 +57,33 @@ namespace drogon * @endcode */ template class StoragePtrType = std::shared_ptr> class IOThreadStorage { + private: + using IsSharedPtr = std::is_same, std::shared_ptr>; + + static_assert(!AutoInit || (AutoInit && IsSharedPtr::value), + "Default initialization only works with std::shared_ptr"); + public: - static const bool isConstructorInitialized = ConstructorInitialize; + static const bool isConstructorInitialized = AutoInit; using StoragePtr = StoragePtrType; using CreatorCallback = std::function; template ::value && - std::is_same, std::shared_ptr>::value && - ConstructorInitialize>::type> + IsSharedPtr::value && AutoInit>::type> IOThreadStorage() : IOThreadStorage([](size_t) { return std::make_shared(); }) { } - template < - typename U = C, - typename = typename std::enable_if< - !ConstructorInitialize || - !std::is_same, std::shared_ptr>::value>::type, - typename = U> + template ::type, + typename = U> IOThreadStorage() : IOThreadStorage([](size_t) { return nullptr; }) { }