fork download
  1. #include <algorithm>
  2. #include <iterator>
  3. #include <vector>
  4. #include <iostream>
  5. #include <array>
  6.  
  7. template<typename T>
  8. struct TypeCheck;
  9.  
  10.  
  11. int main()
  12. {
  13. {
  14. std::vector<int> vec{1};
  15. auto val = vec.begin();
  16. auto check = TypeCheck<decltype(val)>{};
  17. }
  18.  
  19. {
  20. std::vector<bool> vec{true};
  21. auto val = vec.begin();
  22. auto check = TypeCheck<decltype(val)>{};
  23. }
  24.  
  25. {
  26. std::array<int, 1> vec{1};
  27. auto val = vec.begin();
  28. auto check = TypeCheck<decltype(val)>{};
  29. }
  30.  
  31. {
  32. std::array<bool, 1> vec{false};
  33. auto val = vec.begin();
  34. auto check = TypeCheck<decltype(val)>{};
  35. }
  36. }
Compilation error #stdin compilation error #stdout 0s 3468KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:40: error: invalid use of incomplete type 'struct TypeCheck<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'
  auto check = TypeCheck<decltype(val)>{};
                                        ^
prog.cpp:8:8: note: declaration of 'struct TypeCheck<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'
 struct TypeCheck;
        ^
prog.cpp:22:40: error: invalid use of incomplete type 'struct TypeCheck<std::_Bit_iterator>'
  auto check = TypeCheck<decltype(val)>{};
                                        ^
prog.cpp:8:8: note: declaration of 'struct TypeCheck<std::_Bit_iterator>'
 struct TypeCheck;
        ^
prog.cpp:28:40: error: invalid use of incomplete type 'struct TypeCheck<int*>'
  auto check = TypeCheck<decltype(val)>{};
                                        ^
prog.cpp:8:8: note: declaration of 'struct TypeCheck<int*>'
 struct TypeCheck;
        ^
prog.cpp:34:40: error: invalid use of incomplete type 'struct TypeCheck<bool*>'
  auto check = TypeCheck<decltype(val)>{};
                                        ^
prog.cpp:8:8: note: declaration of 'struct TypeCheck<bool*>'
 struct TypeCheck;
        ^
stdout
Standard output is empty