Advertisement
STANAANDREY

variadic args

May 19th, 2025
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #if defined(_MSC_VER)
  2. #include <__msvc_all_public_headers.hpp>
  3. #elif defined(__GNUC__)
  4. #include <bits/stdc++.h>
  5. #else
  6. #error "Unsupported compiler"
  7. #endif
  8. using namespace std;
  9.  
  10. static void Print() {
  11.     cout << endl;
  12. }
  13.  
  14. template<typename T, typename... Args>
  15. static void Print(T t, Args... args) {
  16.     cout << t;
  17.     if constexpr (sizeof...(args) != 0) {
  18.         cout << ", ";
  19.     }
  20.     Print(args...);
  21. }
  22.  
  23. int main() {
  24.     Print(1, 2, 3.1, "asd", 'q');
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement