iostream trouble (accessing basic_ios)

  • Thread starter Michael Bruschkewitz
  • Start date
M

Michael Bruschkewitz

Hello,
I'm somehow annoyed.

This works:
using namespace std; // <-- Don't like this
std::basic_filebuf<char> fb;
fb.open("out.txt",std::ios_base::eek:ut);
std::basic_ofstream<char> ofs;
ofs.basic_ios<char>::rdbuf(&fb);
This too:
typedef basic_ios<char> bioschar; // Don't like this
ofs.bioschar::rdbuf(&fb);
This not:
// Would like this
std::basic_filebuf<char> fb;
fb.open("out.txt",std::ios_base::eek:ut);
std::basic_ofstream<char> ofs;
ofs.std::basic_ios<char>::rdbuf(&fb); // <-- but Error here

Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)

TIA,
Michael B.
 
S

SirMike

Michael said:
Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)
I think it is a compiler problem because on MSVC++ .NET2k3 it compiles
without problems.

SirMike
 
M

Michael Bruschkewitz

I think it is a compiler problem because on MSVC++ .NET2k3 it compiles
without problems.

SirMike
So I'll have to deal with it. Thank you for the fast response.

Michael B.
 
R

Ron Natalie

Michael said:
Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)
I know VC 6 has som problems with name qualification (for example
using std::vector; vector<int>::iterator x;
yeilds errors as well.

If you don't mind, can I ask what you are atrying to accomplish?
If you're going to manage the stream buffers yourself, why not
use a basic_ostream instead (which doesn't overload the stream
buffer). fstream is unprepared for you to replace the buffer
it created (it assumes that the one it fed to the basic_ios is
the same one that will be there at destruction time).
 
C

Chris \( Val \)

message | In article <[email protected]>, (e-mail address removed)
| says...
| > Michael Bruschkewitz wrote:
| > > Generally, I don't like using using. I don't like the typedef version
| > > either. Is there an easy way to make the last version working? (MSVC6)
| > I think it is a compiler problem because on MSVC++ .NET2k3 it compiles
| > without problems.
| >
| > SirMike
| >
| So I'll have to deal with it. Thank you for the fast response.

It also compiles just fine with 'Borland C++ Builder 5.0 UP-1'.

Cheers.
Chris Val
 
M

Michael Bruschkewitz

If you don't mind, can I ask what you are atrying to accomplish?
If you're going to manage the stream buffers yourself, why not
use a basic_ostream instead (which doesn't overload the stream
buffer). fstream is unprepared for you to replace the buffer
it created (it assumes that the one it fed to the basic_ios is
the same one that will be there at destruction time).
That's an example from Langner/Kreft: Standard C++ IOStreams and
Locales.

I create a outstream which is used for logfiles. These logfiles should
not exceed a certain size. This is done by :
class CLogFileBuf : public std::basic_filebuf<char> ...

CLogFileBuf::int_type CLogFileBuf::eek:verflow(int_type _C)
{ int_type rc = inherited::eek:verflow(_C);
++m_counter;
if(m_counter>=m_maxSize && _C=='\n') opennext();
return rc;
}
void CLogFileBuf::eek:pennext()
{ inherited::close();
m_counter=0;
createNextFn(m_fnTempl,m_fn); // template-name, current name
inherited::eek:pen(m_fn.c_str(),std::ios_base::eek:ut);
}

Maybe I need some cleanup, but until now, it works.

Michael B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top