Mail Archives: djgpp/2003/08/27/06:23:00
I'd be very grateful for some help with the following problem
In the code below the line
os.setf( oldflags, ios::basefield);
causes a compilation error:
invalid conversion from 'long int' to 'std::_Ios_Fmtflags'
initializing argument 1 of 'std::_Ios_Fmtflags'
std::ios_base::setf(std::_Ios_Fmtflags, std::_Ios_Fmtflags)'
I've tried changing oldflags to long, unsigned long, int, unsigned int
without success.
In Microsoft Visual C++ 6.0 the Ios.h declares:
inline long setf(long _f,long _m);
inline long setf(long _l);
Presumably in djgpp setf similarly returns & takes parameters of type 'long'
I can't understand why the compiler objects to this.
Mark Hinchcliffe
/*
* friend output operator
* Parameters:
* os - output stream to write to
* bigi - Big_int to print value of
* Return value:
* reference to os
*/
ostream & operator << ( ostream &os,
const Big_int & bigi )
{
long oldflags = os.setf( ios::hex, ios::basefield);
char old_fill = os.fill('0');
bool leading_zero = true;
for( int i = bigi.size_ - 1; i >= 0; i-- ) {
if ( ! leading_zero )
os.width(8);
if ( bigi.number_[i] != 0)
leading_zero = false;
else if (i != 0 && leading_zero)
continue;
os << bigi.number_[i];
}
os.fill(old_fill);
os.setf( oldflags, ios::basefield);
return os;
}
- Raw text -