fork download
  1. #include <iostream>
  2.  
  3. void print(int i, std::string s){
  4. std::cout << i << s;
  5. }
  6.  
  7. bool print(std::pair<int, std::string> const & p){
  8. print(p.first, p.second);
  9. return true;
  10. }
  11. bool ea(){
  12. return true;
  13. }
  14.  
  15. template<typename ... T>
  16. bool ea(std::pair<int, std::string> const & p, T&& ... t){
  17. return print(p) && ea(std::forward<T>(t)...);
  18. }
  19.  
  20. template<typename ... T>
  21. bool ea(std::pair<int, std::string> const & p, T&& ... t){
  22. return print(p) && ea(std::forward<T>(t)...);
  23. }
  24. int main() {
  25. ea({1, "a"}, {2, "b"});
  26. return 0;
  27. }
  28.  
  29.  
  30.  
Compilation error #stdin compilation error #stdout 0.01s 5280KB
stdin
Standard input is empty
compilation info
prog.cpp:21:6: error: redefinition of ‘template<class ... T> bool ea(const std::pair<int, std::__cxx11::basic_string<char> >&, T&& ...)’
 bool ea(std::pair<int, std::string> const & p, T&& ... t){
      ^~
prog.cpp:16:6: note: ‘template<class ... T> bool ea(const std::pair<int, std::__cxx11::basic_string<char> >&, T&& ...)’ previously declared here
 bool ea(std::pair<int, std::string> const & p, T&& ... t){
      ^~
prog.cpp: In function ‘int main()’:
prog.cpp:25:26: error: no matching function for call to ‘ea(<brace-enclosed initializer list>, <brace-enclosed initializer list>)’
     ea({1, "a"}, {2, "b"});
                          ^
prog.cpp:11:6: note: candidate: ‘bool ea()’
 bool ea(){
      ^~
prog.cpp:11:6: note:   candidate expects 0 arguments, 2 provided
prog.cpp:16:6: note: candidate: ‘bool ea(const std::pair<int, std::__cxx11::basic_string<char> >&, T&& ...) [with T = {}]’
 bool ea(std::pair<int, std::string> const & p, T&& ... t){
      ^~
prog.cpp:16:6: note:   candidate expects 1 argument, 2 provided
stdout
Standard output is empty