fork download
  1. template <typename T>
  2. struct event_data;
  3.  
  4. template<typename T>
  5. struct tovoid {
  6. typedef void type;
  7. };
  8.  
  9. template <typename T, typename enable = void>
  10. struct get_data{
  11. typedef event_data<T> type;
  12. };
  13.  
  14. template <typename T>
  15. struct get_data<T, typename tovoid<typename T::data_t>::type >{
  16. typedef typename T::data_t type;
  17. };
  18.  
  19. template <typename T>
  20. struct base{
  21. typedef typename get_data<T>::type data_type;
  22.  
  23. base(){
  24. data_type();
  25. }
  26. };
  27.  
  28. struct non_default_impl: public base<non_default_impl>{
  29. struct data{};
  30.  
  31. typedef data data_t;
  32. };
  33. struct default_impl{
  34.  
  35. };
  36.  
  37. int main(){
  38. non_default_impl e1;
  39. // base<default_impl> e2;
  40. return 0;
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'base<T>::base() [with T = non_default_impl]':
prog.cpp:28:8:   required from here
prog.cpp:24:3: error: invalid use of incomplete type 'base<non_default_impl>::data_type {aka struct event_data<non_default_impl>}'
   data_type();
   ^
prog.cpp:2:8: note: declaration of 'base<non_default_impl>::data_type {aka struct event_data<non_default_impl>}'
 struct event_data;
        ^
stdout
Standard output is empty