fork download
  1. #include <type_traits>
  2.  
  3. template<typename T>
  4. class RefCountedRecycle
  5. {
  6. public:
  7. template<typename U>
  8. static typename std::enable_if<std::is_convertible<U,T>::value, void>::type
  9. Destruct(U *item);
  10.  
  11. template<typename U>
  12. static typename std::enable_if<!std::is_convertible<U,T>::value, void>::type
  13. Destruct(U *item) = delete;
  14. };
  15.  
  16. template<typename T, typename U>
  17. typename std::enable_if<std::is_convertible<U,T>::value, void>::type
  18. RefCountedRecycle<T>::Destruct(U *item)
  19. {
  20. auto p = static_cast<T*>(item);
  21. p->Recycle();
  22. }
  23.  
  24. int main()
  25. {
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:18:41: error: invalid use of incomplete type ‘class RefCountedRecycle<T>’
prog.cpp:4:7: error: declaration of ‘class RefCountedRecycle<T>’
stdout
Standard output is empty