From b8e3f1058c4d224a48401ed6eb98616ed3737461 Mon Sep 17 00:00:00 2001 From: Johannes Kapfhammer Date: Thu, 31 Mar 2022 21:40:48 +0200 Subject: [PATCH 1/3] add license notice to all headers and add LICENSE_1_0.txt --- LICENSE_1_0.txt | 23 +++++++++++++++++++++++ include/bits/include-all.hpp | 4 ++++ include/bits/soi-dbg.hpp | 2 +- include/bits/soi-deprecate.hpp | 4 ++++ include/bits/soi-io.hpp | 4 ++++ include/bits/soi-pretty.hpp | 3 +-- include/bits/soi-redirect.hpp | 4 ++++ include/soi | 5 +++++ 8 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 LICENSE_1_0.txt diff --git a/LICENSE_1_0.txt b/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/include/bits/include-all.hpp b/include/bits/include-all.hpp index 86d5c1d..3cb5911 100644 --- a/include/bits/include-all.hpp +++ b/include/bits/include-all.hpp @@ -1,3 +1,7 @@ +// Copyright Johannes Kapfhammer 2019-2022. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #include #include #include diff --git a/include/bits/soi-dbg.hpp b/include/bits/soi-dbg.hpp index b116e42..1cab972 100644 --- a/include/bits/soi-dbg.hpp +++ b/include/bits/soi-dbg.hpp @@ -1,4 +1,4 @@ -// Copyright Johannes Kapfhammer 2019. +// Copyright Johannes Kapfhammer 2019-2022. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/bits/soi-deprecate.hpp b/include/bits/soi-deprecate.hpp index f87dddf..b934c2f 100644 --- a/include/bits/soi-deprecate.hpp +++ b/include/bits/soi-deprecate.hpp @@ -1,3 +1,7 @@ +// Copyright Johannes Kapfhammer 2019-2022. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #pragma GCC diagnostic error "-Wdeprecated-declarations" struct endl_is_evil_t { diff --git a/include/bits/soi-io.hpp b/include/bits/soi-io.hpp index 14ba043..ad307c9 100644 --- a/include/bits/soi-io.hpp +++ b/include/bits/soi-io.hpp @@ -1,3 +1,7 @@ +// Copyright Johannes Kapfhammer 2019-2022. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #include #include #include diff --git a/include/bits/soi-pretty.hpp b/include/bits/soi-pretty.hpp index bc304a4..c495e69 100644 --- a/include/bits/soi-pretty.hpp +++ b/include/bits/soi-pretty.hpp @@ -1,11 +1,10 @@ -// Copyright Johannes Kapfhammer 2019. +// Copyright Johannes Kapfhammer 2019-2022. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // pretty pretty_printing with c++ // - #ifndef SOI_PRETTY #define SOI_PRETTY diff --git a/include/bits/soi-redirect.hpp b/include/bits/soi-redirect.hpp index 93a7b95..7267883 100644 --- a/include/bits/soi-redirect.hpp +++ b/include/bits/soi-redirect.hpp @@ -1,3 +1,7 @@ +// Copyright Johannes Kapfhammer 2019-2022. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #include #include diff --git a/include/soi b/include/soi index 2589d6a..7f09e77 100644 --- a/include/soi +++ b/include/soi @@ -4,6 +4,11 @@ yet. All will be explained. This header is primarily used so that you don't have to understand every concept all at once. */ +// Copyright Johannes Kapfhammer 2019-2022. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + #include "bits/include-all.hpp" From 33bcd2f073fd8b6991eb50e34cbdfdcf55e18585 Mon Sep 17 00:00:00 2001 From: Johannes Kapfhammer Date: Thu, 31 Mar 2022 21:41:11 +0200 Subject: [PATCH 2/3] add include guard for all headers --- include/bits/prettyprint.hpp | 6 +++--- include/bits/soi-dbg.hpp | 6 +++--- include/bits/soi-deprecate.hpp | 5 +++++ include/bits/soi-io.hpp | 5 +++++ include/bits/soi-redirect.hpp | 4 ++++ include/soi | 9 ++++----- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/bits/prettyprint.hpp b/include/bits/prettyprint.hpp index 1a27b45..4a78cad 100644 --- a/include/bits/prettyprint.hpp +++ b/include/bits/prettyprint.hpp @@ -7,8 +7,8 @@ // // The global operator<< overload hs been removed -#ifndef SOI_PRETTY_PRINT -#define SOI_PRETTY_PRINT +#ifndef SOI_HEADER_PRETTY_PRINT +#define SOI_HEADER_PRETTY_PRINT #include #include @@ -493,4 +493,4 @@ pretty_print(std::basic_ostream &stream, } // namespace soi -#endif // SOI_PRETTY_PRETTY_PRINT +#endif // SOI_HEADER_PRETTY_PRETTY_PRINT diff --git a/include/bits/soi-dbg.hpp b/include/bits/soi-dbg.hpp index 1cab972..15227d4 100644 --- a/include/bits/soi-dbg.hpp +++ b/include/bits/soi-dbg.hpp @@ -7,8 +7,8 @@ // initialize with dbg_init() to enable colorized output // -#ifndef SOI_DBG -#define SOI_DBG +#ifndef SOI_HEADER_DBG +#define SOI_HEADER_DBG #include #include @@ -239,4 +239,4 @@ template T &&identity(T &&t) { return std::forward(t); } #define dbg(...) SOI_DBG_IMPL(SOI_IS_NONEMPTY(__VA_ARGS__), __VA_ARGS__) #endif -#endif // SOI_DBG +#endif // SOI_HEADER_DBG diff --git a/include/bits/soi-deprecate.hpp b/include/bits/soi-deprecate.hpp index b934c2f..cfe8a9e 100644 --- a/include/bits/soi-deprecate.hpp +++ b/include/bits/soi-deprecate.hpp @@ -2,6 +2,9 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef SOI_HEADER_DEPRECATE +#define SOI_HEADER_DEPRECATE + #pragma GCC diagnostic error "-Wdeprecated-declarations" struct endl_is_evil_t { @@ -86,3 +89,5 @@ free(void *ptr, std::size_t new_size); //operator new(std::size_t sz); //[[deprecated("delete is evil. Use a vector.")]] void //operator delete(void *ptr) noexcept; + +#endif // SOI_HEADER_DEPRECATE diff --git a/include/bits/soi-io.hpp b/include/bits/soi-io.hpp index ad307c9..d66f091 100644 --- a/include/bits/soi-io.hpp +++ b/include/bits/soi-io.hpp @@ -2,6 +2,9 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef SOI_HEADER_IO +#define SOI_HEADER_IO + #include #include #include @@ -93,3 +96,5 @@ void print(Arg&& arg, Args&&... args) { void print() { std::cout << '\n'; } + +#endif // SOI_HEADER_IO diff --git a/include/bits/soi-redirect.hpp b/include/bits/soi-redirect.hpp index 7267883..95b5059 100644 --- a/include/bits/soi-redirect.hpp +++ b/include/bits/soi-redirect.hpp @@ -2,6 +2,9 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef SOI_HEADER_REDIRECT +#define SOI_HEADER_REDIRECT + #include #include @@ -95,3 +98,4 @@ void redirect_input(const char *filename) { void redirect_input(std::string const &filename) { redirect_input(filename.c_str()); } +#endif // SOI_HEADER_REDIRECT diff --git a/include/soi b/include/soi index 7f09e77..d959663 100644 --- a/include/soi +++ b/include/soi @@ -1,14 +1,11 @@ // -*- c++ -*- -/* - Students: please don't try to understand the details of headers just - yet. All will be explained. This header is primarily used so that you don't - have to understand every concept all at once. -*/ // Copyright Johannes Kapfhammer 2019-2022. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#ifndef SOI_HEADER_INCLUDED +#define SOI_HEADER_INCLUDED #include "bits/include-all.hpp" @@ -93,3 +90,5 @@ using soi::interactive_task; #define int int64_t using namespace std; + +#endif // SOI_HEADER_INCLUDED From 19ddcef24eb55bdb5ddb817c1d91bfa04c8cb8dd Mon Sep 17 00:00:00 2001 From: Johannes Kapfhammer Date: Thu, 31 Mar 2022 21:46:22 +0200 Subject: [PATCH 3/3] 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