fork download
  1. #include<tuple>
  2. #include<string>
  3.  
  4. template<class T1, class T2>
  5. void fun(std::tuple<T1, T2> t, std::string other){}
  6.  
  7. int main(){
  8. fun(std::tuple<double, int>(2.,3), std::string("other")); // ok
  9. fun(std::make_tuple(2.,3), std::string("other")); // ok, but trying to avoid `make_tuple`
  10. fun({2.,3},std::string("other")); // desired syntax but
  11. // giving compilation error: candidate template ignored: couldn't infer template argument 'T1' void fun(std::tuple<T1, T2> t)
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.7/tuple:35:0,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
prog.cpp:5:15: error: variable or field ‘fun’ declared void
prog.cpp:5:10: error: ‘tuple’ is not a member of ‘std’
prog.cpp:5:23: error: expected primary-expression before ‘,’ token
prog.cpp:5:27: error: expected primary-expression before ‘>’ token
prog.cpp:5:29: error: ‘t’ was not declared in this scope
prog.cpp:5:44: error: expected primary-expression before ‘other’
prog.cpp: In function ‘int main()’:
prog.cpp:8:9: error: ‘tuple’ is not a member of ‘std’
prog.cpp:8:20: error: expected primary-expression before ‘double’
prog.cpp:8:28: error: expected primary-expression before ‘int’
prog.cpp:8:60: error: ‘fun’ was not declared in this scope
prog.cpp:9:9: error: ‘make_tuple’ is not a member of ‘std’
prog.cpp:10:8: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
stdout
Standard output is empty