1

I have this snippet of code:

class myistringstream : public std::istringstream
{
public:
   using std::istringstream::operator>>;

   myistringstream (const std::string &str): std::istringstream(str)
   {
   }

   myistringstream& operator >> (unsigned char& _MyChar)
   {
      int temp;
      // my stuff here with temp and _MyChar ... 

      std::istringstream::operator>> (temp);
      _MyChar = static_cast<unsigned char> (temp);
      return *this;
   }
};

this i the usage: file: myCpp.cpp

54:    unsigned char myUnsignedChar;
55:    int myIntVar;
56:    myistringstream ss (myStr);
57:    ss >> myIntVar;        //
58:    ss >> myUnsignedChar;

what I want is a particular implementation of the >> operator in a specified case (unsigned char)! the good news is that works perfectly on Visual Studio (2008, 2010) !

but does not work on Borland C++! it gives me this warning

[C++ Warning] myCpp.cpp(57): W8030 Temporary used for parameter '_MyChar' in call to 'myistringstream::operator >>(unsigned char &)'

I realized that I don't "see" all the other ">>" implementation (for the other type) of the base class (istringstream) even though I used the using std::istringstream::operator>>; directive!

again on VS works perfectly .... do you see something wrong/error ?

TIA :-)

Kasper
  • 685
  • 2
  • 11
  • 30

0 Answers0