Advertisement
frasl

Untitled

Feb 11th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. template<typename T>
  2. T adder(T v) {
  3.   return v;
  4. }
  5.  
  6. template<typename T, typename... Args>
  7. T adder(T first, Args... args) {
  8.   return first + adder(args...);
  9. }
  10.  
  11.  
  12. long sum = adder(1, 2, 3, 8, 7);
  13.  
  14. std::string s1 = "x", s2 = "aa", s3 = "bb", s4 = "yy";
  15. std::string ssum = adder(s1, s2, s3, s4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement