From f0ca96d462491a406aa975b3f4670a72b3a721e2 Mon Sep 17 00:00:00 2001 From: Oleg Endo Date: Sun, 9 Jul 2017 15:04:49 +0900 Subject: [PATCH 1/3] include instead of avoid bloat caused by and std::cout and friends in apps where iostream are not used. --- src/json.hpp | 2 +- test/src/unit-readme.cpp | 1 + test/src/unit-unicode.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/json.hpp b/src/json.hpp index 612c7e58..b378c77d 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -43,7 +43,7 @@ SOFTWARE. #include // function, hash, less #include // initializer_list #include // hex -#include // istream, ostream +#include // istream, ostream #include // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator #include // numeric_limits #include // locale diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 1b22f1b3..e921c4b6 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -36,6 +36,7 @@ using nlohmann::json; #include #include #include +#include TEST_CASE("README", "[hide]") { diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index 9b379d96..e19905d5 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -33,6 +33,7 @@ SOFTWARE. using nlohmann::json; #include +#include extern size_t calls; size_t calls = 0; From b753cb6ee75cc59559b1f9976b62efae25bb76f7 Mon Sep 17 00:00:00 2001 From: Oleg Endo Date: Sun, 9 Jul 2017 15:19:08 +0900 Subject: [PATCH 2/3] use std::make_shared --- src/json.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index b378c77d..abf6b1f6 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6634,17 +6634,17 @@ class basic_json static std::shared_ptr> create(std::vector& vec) { - return std::shared_ptr(new output_vector_adapter(vec)); + return std::make_shared>(vec); } static std::shared_ptr> create(std::ostream& s) { - return std::shared_ptr(new output_stream_adapter(s)); + return std::make_shared>(s); } static std::shared_ptr> create(std::string& s) { - return std::shared_ptr(new output_string_adapter(s)); + return std::make_shared>(s); } }; @@ -8767,19 +8767,19 @@ class basic_json /// input adapter for input stream static std::shared_ptr create(std::istream& i) { - return std::shared_ptr(new cached_input_stream_adapter<16384>(i)); + return std::make_shared> (i); } /// input adapter for input stream static std::shared_ptr create(std::istream&& i) { - return std::shared_ptr(new cached_input_stream_adapter<16384>(i)); + return std::make_shared>(i); } /// input adapter for buffer static std::shared_ptr create(const char* b, size_t l) { - return std::shared_ptr(new input_buffer_adapter(b, l)); + return std::make_shared(b, l); } // derived support From e3bb156f826edaa25dd4186cd094440274b9b8b1 Mon Sep 17 00:00:00 2001 From: Oleg Endo Date: Sun, 9 Jul 2017 15:20:28 +0900 Subject: [PATCH 3/3] fix typo --- src/json.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/json.hpp b/src/json.hpp index abf6b1f6..1bde08ce 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6675,7 +6675,7 @@ class basic_json std::vector& v; }; - /// putput adapter for output streams + /// output adapter for output streams template class output_stream_adapter : public output_adapter {