Can someone tell me why the code snippet below that I wrote during compilation keeps complaining istream_iterator is not a member of std, please can you tell? Thanks guys
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <fstream>
struct field_reader: std::ctype<char> {
field_reader(): std::ctype<char>(get_table()) {}
static std::ctype_base::mask const* get_table() {
static std::vector<std::ctype_base::mask>
rc(table_size, std::ctype_base::mask());
rc[';'] = std::ctype_base::space;
return &rc[0];
}
};
struct Stud{
double VehicleID;
double FinancialYear;
double VehicleType;
double Manufacturer;
double ConditionScore;
friend std::istream &operator>>(std::istream &is, Stud &s) {
return is >> s.VehicleID >> s.FinancialYear >> s.VehicleType >> s.Manufacturer >> s.ConditionScore;
}
friend std::ostream &operator<<(std::ostream &os, Stud const &s) {
return os << s.VehicleID << "\t"
<< s.FinancialYear << "\t"
<< s.VehicleType << "\t"
<< s.Manufacturer << "\t"
<< s.ConditionScore;
}
};
int main(){
std::ifstream in("VehicleData_cs2v_1.csv");
in.imbue(std::locale(std::locale(), new field_reader));
std::vector<Stud> studs{(std::istream_iterator<Stud>(in)),
std::istream_iterator<Stud>()};
for (auto s : studs)
std::cout << s << "\n";
}
Therefore, if you notice a problem, let me know, because I canβt say it now, and I believe that I have included all the necessary include libraries
Lexka source
share