From d7f4e604921e772a6045e6bf18d4a35181a7939c Mon Sep 17 00:00:00 2001 From: subcrip Date: Sat, 21 Sep 2024 17:47:31 +0800 Subject: [PATCH] Update template.cc Signed-off-by: subcrip --- template.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/template.cc b/template.cc index cbb2df8..b29d551 100644 --- a/template.cc +++ b/template.cc @@ -231,9 +231,24 @@ template void __read(T& x, U&... args) { cin >> x; __ #define deb(...) debug(make_tuple(__VA_ARGS__)) /* pops */ -#define poptop(q, ...) __AS_PROCEDURE(auto [__VA_ARGS__] = q.top(); q.pop();) -#define popback(q, ...) __AS_PROCEDURE(auto [__VA_ARGS__] = q.back(); q.pop_back();) -#define popfront(q, ...) __AS_PROCEDURE(auto [__VA_ARGS__] = q.front();q.pop_front();) +template +inline auto poptop(Container& q) { + auto ret = q.top(); + q.pop(); + return ret; +} +template +inline auto popback(Container& q) { + auto ret = q.back(); + q.pop_back(); + return ret; +} +template +inline auto popfront(Container& q) { + auto ret = q.front(); + q.pop_front(); + return ret; +} /* math */ template