this template is not working in my sublime text
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << '{' << p.first << ", " << p.second << '}'; }
template < class T, class = decay_t<decltype(*begin(declval()))>, class = enable_if_t < !is_same<T, string>::value >> ostream & operator<<(ostream &os, const T &c) { os << '['; for (auto it = c.begin(); it != c.end(); ++it) os << &", "[2 * (it == c.begin())] << *it; return os << ']'; } //support up to 5 args
define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
define _FE_0(_CALL, ...)
define _FE_1(_CALL, x) _CALL(x)
define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, VA_ARGS)
define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, VA_ARGS)
define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, VA_ARGS)
define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, VA_ARGS)
define FOR_EACH_MACRO(MACRO, ...) \
NTH_ARG(dummy, ##_VA_ARGS__, _FE_5, _FE_4, _FE_3, FE_2, FE_1, FE_0) \ (MACRO, ##_VA_ARGS) //Change output format here
define out(x) #x " = " << x << "; "
define dbg(...) \
cerr << "Line " << LINE << ": " FOR_EACH_MACRO(out, VA_ARGS) << "\n"
I think it is because i may be using older c++ compiler,i do not know how to upgrade to c++ 17,please help
but this is working
include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << ''' << x << ''';} void __print(const char *x) {cerr << '"' << x << '"';} void __print(const string &x) {cerr << '"' << x << '"';} void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void print(T t, V... v) {_print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}