fork download
  1. #include <cstddef>
  2. #include <iostream>
  3.  
  4. template <typename Derived>
  5. struct B
  6. {
  7. typedef typename Derived::Type Type2;
  8.  
  9. Type2 operator[] (const std::size_t i) { return Derived::_kernel[i]; }
  10.  
  11. static const std::size_t _size = sizeof(Derived::_kernel) / sizeof(Type2);
  12. };
  13.  
  14. template <typename T>
  15. struct D : public B< D<T> >
  16. {
  17. typedef T Type;
  18. static const T _kernel[];
  19. };
  20.  
  21. template <typename T>
  22. const T D<T>::_kernel[] = {T(1.0)};
  23.  
  24. int main()
  25. {
  26. D<float> d;
  27. std::cout << D<float>::_size << std::endl;
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 3096KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'struct B<D<float> >':
prog.cpp:15:8:   required from 'struct D<float>'
prog.cpp:26:11:   required from here
prog.cpp:7:33: error: no type named 'Type' in 'struct D<float>'
  typedef typename Derived::Type Type2;
                                 ^
stdout
Standard output is empty