Guest User

Untitled

a guest
Oct 16th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. template<typename... Args>
  2. void print(const Args&... args) {
  3. (std::cout << ... << args);
  4. }
  5.  
  6. template<typename... Args>
  7. void print(const Args&... args) {
  8. auto f{[](auto&& x) { cout << x << " "; }};
  9. (f(args),...);
  10. }
  11.  
  12. template<typename... Args>
  13. void print(const char * delim, const Args&... args) {
  14. auto f{[delim](auto&& x) { cout << x << delim; }};
  15. (f(args),...);
  16. }
  17.  
  18. template<typename... Args>
  19. void print(const char * delim, const Args&... args) {
  20. int count = sizeof...(args);
  21. auto f{[delim, &count](auto&& x) { cout << x; if (--count) cout << delim; }};
  22. (f(args),...);
  23. }
Add Comment
Please, Sign In to add comment