I do not understand this cryptic error message, but I get 30 of
`'value_type' : is not a member of 'TextFileLineBuffer'`
when I compiled the following code in VC ++ 6 with //*** lines without comment.
Of course, if I commented on this, it compiles fine.
I think I tried different attempts in vain for the last two hours. Any advice would be appreciated.
#include <list> #include <string> #include <iostream> #include <fstream> #include <algorithm> #include <iterator> //wrapper for a string line struct TextLine { std::string m_sLineContent; operator std::string const& () const { return m_sLineContent; } friend std::istream& operator>>(std::istream& stream, TextLine& line) { return std::getline(stream, line.m_sLineContent); } }; //this is a version of fixed size of string queue for easy text file reading class TextFileLineBuffer { public: TextFileLineBuffer(size_t lc, const char* fileName) : m_iLineCount(lc), m_sFileName(fileName) { std::ifstream file(fileName); //*** std::copy(std::istream_iterator<TextLine>(file), //*** std::istream_iterator<TextLine>(), //*** std::back_inserter(*this)); } void push_back(std::string const& line) { m_sBuffer.insert(m_sBuffer.end(),line); if (m_sBuffer.size() > m_iLineCount) { m_sBuffer.erase(m_sBuffer.begin()); } } const char* c_str() const { std::string returnValue(""); for (const_iterator it = begin(); it != end(); ++it) { returnValue = returnValue + *it; } return returnValue.c_str(); } typedef std::list<std::string> Container; typedef Container::const_iterator const_iterator; typedef Container::const_reference const_reference; const_iterator begin() const { return m_sBuffer.begin(); } const_iterator end() const { return m_sBuffer.end();} private: size_t m_iLineCount; std::list<std::string> m_sBuffer; std::string m_sFileName; };
source share