From fe02073b12dcbda9bd2109199e513bb87999b4b6 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Thu, 7 Apr 2022 17:11:02 +0300 Subject: [PATCH] fix const --- bin/main.cpp | 3 +++ src/iterators/sequence_ostream_iterator.hpp | 2 +- src/logger/logger.cpp | 6 +++--- src/logger/logger.hpp | 6 +++--- src/string/string_concat_helper.hpp | 2 +- src/utils/utils.hpp | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bin/main.cpp b/bin/main.cpp index 4c6fdf5..3a1c5fe 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -181,5 +181,8 @@ int main(int argc, char *argv[]) {// ex: utils::exec hack::log()(hack::utils::exec("ls")); + hack::log()(hack::utils::exec("pwd")); + auto t = hack::utils::exec("pwd"); + hack::log::type_trace(t); } } diff --git a/src/iterators/sequence_ostream_iterator.hpp b/src/iterators/sequence_ostream_iterator.hpp index 6c2a362..5de87b1 100644 --- a/src/iterators/sequence_ostream_iterator.hpp +++ b/src/iterators/sequence_ostream_iterator.hpp @@ -12,7 +12,7 @@ namespace hack::iterators private: std::basic_ostream* os_; - const std::string devider_ = ", "; + std::string devider_ = ", "; std::size_t size_; public: diff --git a/src/logger/logger.cpp b/src/logger/logger.cpp index 520f4df..abcb4fe 100644 --- a/src/logger/logger.cpp +++ b/src/logger/logger.cpp @@ -5,17 +5,17 @@ namespace hack std::string log::devider = " "; int log::count = 0; - log::log(const std::string devider_, std::experimental::source_location location_) : location { location_ } + log::log(std::string devider_, std::experimental::source_location location_) : location { location_ } { this->devider = devider_; } - warn::warn(const std::string devider_, std::experimental::source_location location_) : location { location_ } + warn::warn(std::string devider_, std::experimental::source_location location_) : location { location_ } { this->devider = devider_; } - error::error(const std::string devider_, std::experimental::source_location location_) : location { location_ } + error::error(std::string devider_, std::experimental::source_location location_) : location { location_ } { this->devider = devider_; } diff --git a/src/logger/logger.hpp b/src/logger/logger.hpp index b6a5c1a..eae2fc1 100644 --- a/src/logger/logger.hpp +++ b/src/logger/logger.hpp @@ -24,7 +24,7 @@ namespace hack class log { public: - log(const std::string devider_ = ", ", std::experimental::source_location location_ = std::experimental::source_location::current()); + log(std::string devider_ = ", ", std::experimental::source_location location_ = std::experimental::source_location::current()); log(log&) = delete; log(log&&) = delete; @@ -135,7 +135,7 @@ namespace hack class warn : public log { public: - warn(const std::string devider_ = ", ", std::experimental::source_location location_ = std::experimental::source_location::current()); + warn(std::string devider_ = ", ", std::experimental::source_location location_ = std::experimental::source_location::current()); warn(log&) = delete; warn(log&&) = delete; @@ -162,7 +162,7 @@ namespace hack class error : public log { public: - error(const std::string devider_ = ", ", std::experimental::source_location location_ = std::experimental::source_location::current()); + error(std::string devider_ = ", ", std::experimental::source_location location_ = std::experimental::source_location::current()); error(log&) = delete; error(log&&) = delete; diff --git a/src/string/string_concat_helper.hpp b/src/string/string_concat_helper.hpp index 73b0748..d79aa8a 100644 --- a/src/string/string_concat_helper.hpp +++ b/src/string/string_concat_helper.hpp @@ -70,7 +70,7 @@ namespace hack::string }; template - Stream& operator<<(Stream& stream, const string_concat_helper strings) + Stream& operator<<(Stream& stream, string_concat_helper strings) { return stream << static_cast(strings); } diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index c2b53d6..ecc5728 100644 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -48,13 +48,13 @@ namespace hack::utils inline std::string exec(const char* cmd) { - std::array buffer; std::string result; + std::array buffer; std::unique_ptr pipe(popen(cmd, "r"), pclose); if (!pipe) { - throw std::runtime_error("popen() failed!"); + throw std::runtime_error("bash cmd failed"); } while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)