22 #ifndef GEARS_IO_LINES_HPP
23 #define GEARS_IO_LINES_HPP
41 template<
typename CharT =
char,
typename Traits = std::
char_traits<CharT>>
42 struct line_iterator : std::iterator<std::input_iterator_tag, std::basic_string<CharT, Traits>> {
44 std::basic_istream<CharT, Traits>* reader;
45 std::basic_string<CharT, Traits> value;
49 line_iterator(std::basic_istream<CharT, Traits>& out) noexcept: reader(&out) {
50 status = reader && *reader && std::getline(*reader, value);
53 auto operator++() noexcept -> decltype(*
this) {
54 status = reader && *reader && std::getline(*reader, value);
64 auto operator*() noexcept -> decltype(value) {
68 auto operator->() noexcept -> decltype(&value) {
73 return (status == other.status) && (!status || reader == other.reader);
77 return not (*
this == other);
90 template<
typename CharT,
typename Traits>
93 std::basic_istream<CharT, Traits>& in;
95 line_reader(std::basic_istream<CharT, Traits>& in) noexcept: in(in) {}
131 template<
typename CharT,
typename Traits>
138 #endif // GEARS_IO_LINES_HPP