Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant.

###IterableStream.h #include #include

IterableStream.h

#include <iostream>
#include <iterator>
namespace ThorsAnvil::Util
{
 
template<typename T>
class IterableStream
{
 std::istream& stream;
 public:
 IterableStream(std::istream& stream)
 : stream(stream)
 {}
 operator std::istream&() {return stream;}
 std::istream_iterator<T> begin() {return std::istream_iterator<T>(stream);}
 std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
}

Example usage

#include "IterableStream.h"
#include <iostream>
#include <fstream>
namespace TaU = ThorsAnvil::Util;
int main()
{
 std::ifstream x("plop");
 for(auto const& y: TaU::IterableStream<int>(x)) {
 std::cout << y << "\n";
 }
}

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant.

###IterableStream.h #include #include

namespace ThorsAnvil::Util
{
 
template<typename T>
class IterableStream
{
 std::istream& stream;
 public:
 IterableStream(std::istream& stream)
 : stream(stream)
 {}
 operator std::istream&() {return stream;}
 std::istream_iterator<T> begin() {return std::istream_iterator<T>(stream);}
 std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
}

Example usage

#include "IterableStream.h"
#include <iostream>
#include <fstream>
namespace TaU = ThorsAnvil::Util;
int main()
{
 std::ifstream x("plop");
 for(auto const& y: TaU::IterableStream<int>(x)) {
 std::cout << y << "\n";
 }
}

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant.

IterableStream.h

#include <iostream>
#include <iterator>
namespace ThorsAnvil::Util
{
 
template<typename T>
class IterableStream
{
 std::istream& stream;
 public:
 IterableStream(std::istream& stream)
 : stream(stream)
 {}
 operator std::istream&() {return stream;}
 std::istream_iterator<T> begin() {return std::istream_iterator<T>(stream);}
 std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
}

Example usage

#include "IterableStream.h"
#include <iostream>
#include <fstream>
namespace TaU = ThorsAnvil::Util;
int main()
{
 std::ifstream x("plop");
 for(auto const& y: TaU::IterableStream<int>(x)) {
 std::cout << y << "\n";
 }
}
Tweeted twitter.com/StackCodeReview/status/926161603892056065
edited tags
Link
200_success
  • 145.5k
  • 22
  • 190
  • 478
added 44 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant.

###IterableStream.h #include #include

namespace ThorsAnvil::Util
{
 
template<typename T>
class IterableStream
{
 std::istream& stream;
 public:
 IterableStream(std::istream& stream)
 : stream(stream)
 {}
 operator std::istream&() {return stream;}
 std::istream_iterator<T> begin() {return std::istream_iterator<T>(stream);}
 std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
}

Example usage

#include "IterableStream.h"
#include <iostream>
#include <fstream>
namespace TaU = ThorsAnvil::Util;
int main()
{
 std::ifstream x("plop");
 for(auto const& y: TaU::IterableStream<int>(x)) {
 std::cout << y << "\n";
 }
}

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant.

###IterableStream.h #include #include

namespace ThorsAnvil::Util
{
 
template<typename T>
class IterableStream
{
 std::istream& stream;
 public:
 IterableStream(std::istream& stream)
 : stream(stream)
 {}
 operator std::istream&() {return stream;}
 std::istream_iterator<T> begin() {return std::istream_iterator<T>(stream);}
 std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
}

Example usage

#include "IterableStream.h"
#include <iostream>
#include <fstream>
int main()
{
 std::ifstream x("plop");
 for(auto const& y: IterableStream<int>(x)) {
 std::cout << y << "\n";
 }
}

Hoping somebody has knowledge of the range based additions going into the standard. So they can point out all the things I need to add to make it compliant.

###IterableStream.h #include #include

namespace ThorsAnvil::Util
{
 
template<typename T>
class IterableStream
{
 std::istream& stream;
 public:
 IterableStream(std::istream& stream)
 : stream(stream)
 {}
 operator std::istream&() {return stream;}
 std::istream_iterator<T> begin() {return std::istream_iterator<T>(stream);}
 std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
}

Example usage

#include "IterableStream.h"
#include <iostream>
#include <fstream>
namespace TaU = ThorsAnvil::Util;
int main()
{
 std::ifstream x("plop");
 for(auto const& y: TaU::IterableStream<int>(x)) {
 std::cout << y << "\n";
 }
}
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /