#include <iostream> template<typename T>struct Foo{ T d_val; size_t d_other_val; template<size_t idx> Foo(T val) { d_val = val; d_other_val = idx; }}; int main() { Foo<double> f = Foo<4>(2.6); std::cout << f.d_val << " " << f.d_other_val << '\n';}
Standard input is empty
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'
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!