C++ Templates – Guarantee A Type Definition Has a Particular Constructor Signature?
#include <iostream> #include <vector> #include <functional> struct AppleMakeInfo {}; template <typename T> class Apple { static_assert(std::is_base_of<AppleMakeInfo, T>::value, “T must be derived from AppleMakeInfo”); public: std::function<void()> deleteFunc; ~Apple() { deleteFunc(); } Apple(T* aMI) {}; }; template <typename T,typename U> class AppleManager { static_assert(std::is_base_of<AppleMakeInfo, T>::value, “T must be derived from AppleMakeInfo”); static_assert(std::is_base_of<Apple<T>, U>::value, “U must be derived […]