feat: add ostream operator to comment containers

This commit is contained in:
ToruNiina
2019-06-28 14:57:45 +09:00
parent 6b5fd349aa
commit 28b3f7d6fb

View File

@@ -187,6 +187,17 @@ inline void swap(preserve_comments& lhs, preserve_comments& rhs)
return; return;
} }
template<typename charT, typename traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const preserve_comments& com)
{
for(const auto& c : com)
{
os << '#' << c << '\n';
}
return os;
}
namespace detail 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;} inline void swap(const discard_comments&, const discard_comments&) noexcept {return;}
template<typename charT, typename traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const discard_comments&)
{
return os;
}
} // toml11 } // toml11
#endif// TOML11_COMMENTS_HPP #endif// TOML11_COMMENTS_HPP