From 28b3f7d6fbb026a917f5f89f9dcb450a4c3f816f Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 28 Jun 2019 14:57:45 +0900 Subject: [PATCH] feat: add ostream operator to comment containers --- toml/comments.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/toml/comments.hpp b/toml/comments.hpp index 98f36c8..3ce88a1 100644 --- a/toml/comments.hpp +++ b/toml/comments.hpp @@ -187,6 +187,17 @@ inline void swap(preserve_comments& lhs, preserve_comments& rhs) return; } +template +std::basic_ostream& +operator<<(std::basic_ostream& os, const preserve_comments& com) +{ + for(const auto& c : com) + { + os << '#' << c << '\n'; + } + return os; +} + namespace detail { @@ -381,5 +392,12 @@ inline bool operator>=(const discard_comments&, const discard_comments&) noexcep inline void swap(const discard_comments&, const discard_comments&) noexcept {return;} +template +std::basic_ostream& +operator<<(std::basic_ostream& os, const discard_comments&) +{ + return os; +} + } // toml11 #endif// TOML11_COMMENTS_HPP