fork(1) download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. struct Foo
  5. {
  6. T d_val;
  7. size_t d_other_val;
  8. template<size_t idx>
  9. Foo(T val)
  10. {
  11. d_val = val;
  12. d_other_val = idx;
  13. }
  14. };
  15.  
  16.  
  17. int main() {
  18. Foo<double> f = Foo<4>(2.6);
  19.  
  20. std::cout << f.d_val << " " << f.d_other_val << '\n';
  21. }
Compilation error #stdin compilation error #stdout 0s 3136KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:18:23: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> struct Foo'
  Foo<double> f = Foo<4>(2.6);
                       ^
prog.cpp:18:23: error:   expected a type, got '4'
stdout
Standard output is empty