fork(1) download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. constexpr size_t get_pretty_function_size()
  5. {
  6. return sizeof(__PRETTY_FUNCTION__);
  7. }
  8.  
  9. static_assert(87 == get_pretty_function_size<int>(), "invalid size");
  10. static_assert(90 == get_pretty_function_size<double>(), "invalid size");
  11. static_assert(116 == get_pretty_function_size<std::string>(), "invalid size");
  12.  
  13. template <int SS> struct sizeof_struct { char a__[SS]; };
  14.  
  15. template <typename T, int Size>
  16. inline sizeof_struct<Size> count_of_array(T (&a)[Size]) {}
  17. template <char const* C> struct SSS;
  18. int main()
  19. {
  20. typedef SSS<""> S_TY;
  21. static_assert(sizeof(count_of_array("")) == 1, "It is not a compiletime array");
  22. }
Compilation error #stdin compilation error #stdout 0s 4388KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:18: error: ‘""’ is not a valid template argument for type ‘char*’ because string literals can never be used in this context
    typedef SSS<""> S_TY;
                  ^
stdout
Standard output is empty