Category : istream

I am completely new to the c++ and I have problem with managing input. I have a program where I want to be possible to read input from console but also from the file. I have class with private field std::istream &input_stream; and in constructor I set this input_stream as std::cin, however when my program ..

Read more

I am a beginner in c++ so thank you in advance for help. My question is: what is the correct way to call the function that expects std::istream&. Tried it with read(std::cin); , but I get error from compiler. typedef double Element; template<typename T> std::list<T> read(std::istream& i) { Element input; std::list<Element> l; while(i>>input) { l.push_back(input); ..

Read more

I’m able to overload operator>> for my own classes, but I get this error: no match for ‘operator>>’ (operand types are ‘std::istream_iterator<std::vector<int> >::istream_type’ {aka ‘std::basic_istream<char>’} and ‘std::vector<int>’) when I try to do it for a std::vector. I don’t understand the error. Why does it work for my MyClass but not a std::vector? #include <iostream> #include ..

Read more

I have a String class. I want to overload operator >>. Found the following way, but as far as I understand, the zero character is not added at the end (line terminator). How can I write a good operator >>? class String { public: char* str; size_t size; size_t capacity; ~String(); String(const char*); friend std::istream& ..

Read more

First I want to predicate this issue as only being a problem on OS X using Xcode and the clang compiler. The following code compiles with gcc (9 and 10) on linux (RH8) and Visual Studio (2019). However it will not compile on Xcode(13.1) with clang on Big Sur. std::basic_fstream<char16_t> stream; rapidjson::BasicIStreamWrapper<std::basic_fstream<char16_t>> iwrapper(stream); rapidjson::GenericStreamWrapper< rapidjson::BasicIStreamWrapper<std::basic_fstream<char16_t>>, ..

Read more