fork download
  1. #include <vector>
  2.  
  3. void f(std::vector<double> v);
  4.  
  5. template <class T>
  6. void g(T&& t)
  7. {
  8. f(t);
  9. }
  10.  
  11. int m()
  12. {
  13. f({1, 2}); // that's OK
  14. g({1, 2}); // that's not
  15. }
  16.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int m()':
prog.cpp:14:11: warning: deducing 'T' as 'std::initializer_list<int>'
prog.cpp:6:6: warning:   in call to 'void g(T&&) [with T = std::initializer_list<int>]'
prog.cpp:14:11: warning:   (you can disable this with -fno-deduce-init-list)
prog.cpp: In function 'void g(T&&) [with T = std::initializer_list<int>]':
prog.cpp:14:11:   instantiated from here
prog.cpp:8:3: error: conversion from 'std::initializer_list<int>' to non-scalar type 'std::vector<double>' requested
stdout
Standard output is empty