read template

Revision en2, by amrit2kbron, 2021-04-21 10:06:56
template<typename T>
inline void read(T &x){
    x = 0; T f = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch))  {x = x * 10 + ch &mdash; '0'; ch = getchar();}
    x *= f;
}

Can anyone tell me how this template works

or infact any of these templates

~~~~~ template class y_combinator_result { Fun fun_; public: template explicit y_combinator_result(T &&fun): fun_(std::forward(fun)) {} template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward(args)...); } }; template decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t>(std::forward(fun)); }

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

ifdef NEAL_DEBUG

define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

else

define dbg(...)

endif~~~~~

I found these in neal's submissions

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English amrit2kbron 2021-04-21 10:08:07 23
en2 English amrit2kbron 2021-04-21 10:06:56 191
en1 English amrit2kbron 2021-04-21 10:05:54 1577 Initial revision (published)