From 19ddcef24eb55bdb5ddb817c1d91bfa04c8cb8dd Mon Sep 17 00:00:00 2001 From: Johannes Kapfhammer Date: Thu, 31 Mar 2022 21:46:22 +0200 Subject: [PATCH] add print_no_space function for use in first round --- example.cpp | 5 +++++ include/bits/soi-io.hpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/example.cpp b/example.cpp index bd88056..bbdca21 100644 --- a/example.cpp +++ b/example.cpp @@ -72,6 +72,11 @@ signed main() { print(tuple{unordered_map{{3,"three"},{1,"one"}}}); print(unordered_set{3,1,4}); + print_no_space("Case #", 0, ": "); + print_no_space(42); + print_no_space(); + print(); + redirect_input("example.in"); print("reading from example.in:", read_string()); redirect_input("example.in"); diff --git a/include/bits/soi-io.hpp b/include/bits/soi-io.hpp index d66f091..a596e09 100644 --- a/include/bits/soi-io.hpp +++ b/include/bits/soi-io.hpp @@ -97,4 +97,10 @@ void print() { std::cout << '\n'; } +template +void print_no_space(Args&&... args) { + using expander = bool[]; + (void)expander{0, (soi::io::print(std::cout, std::forward(args)), false)...}; +} + #endif // SOI_HEADER_IO