fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3. #include <vector>
  4. #include <string>
  5. #include <array>
  6. using namespace std;
  7.  
  8. template<typename T>
  9. struct is_template : std::false_type
  10. {
  11. };
  12.  
  13. template<template <typename... > class T, typename...Args>
  14. struct is_template<T<Args...>> : std::true_type
  15. {
  16. };
  17.  
  18. int main() {
  19. static_assert(is_template<std::vector<int>>::value == true, "correct");
  20. static_assert(is_template<int>::value == false, "correct");
  21.  
  22. static_assert(is_template<std::string>::value == true, "correct");
  23. static_assert(is_template<std::array<int, 2>>::value == true, "correct"); // WRONG COMPILE ERROR
  24. return 0;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23:2: error: static assertion failed: correct
  static_assert(is_template<std::array<int, 2>>::value == true, "correct"); // WRONG COMPILE ERROR
  ^~~~~~~~~~~~~
stdout
Standard output is empty