Guest User

VariadicMacros.cpp

a guest
Jul 3rd, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include <string>
  2.  
  3. template<typename T>
  4. T add(const T& arg)
  5. {
  6.   return arg;
  7. }
  8.  
  9. template<typename T, typename... Args>
  10. T add(const T& arg, const Args&... args)
  11. {
  12.   return arg + add(args...);
  13. }
  14.  
  15. int main()
  16. {
  17.   add("a", "b", "c");
  18.   return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment