Overriding std::fstream << and >> operators
Hi
I've overriden the << and >> operators to write data in binary format (instead of text). The function seem to work ok but I'd like to know if they are sufficient and whether they be improved upon. So here they are. Tthey are members of a class called BinStream that inherits from std::fstream.
Code:
template <typename T> BinStream& operator << (const T& input)
{
T&& temp= std::move(input);
this->write(reinterpret_cast<char*>(&temp), sizeof(T));
return *this;
}
template <typename T> BinStream& operator >> (T& input)
{
this->read(reinterpret_cast<char*>(&input), sizeof(T));
return *this;
}