Topic: puzzled at new iostream headers


Author: Ingo Luetkebohle <Ingo@identity.de>
Date: 1996/08/20
Raw View
I was used to the older iostream implementation and when I set out to
use the new one, I was really puzzled. There's no "real" class in these
headers -- just templates. Yet, if I use the standard classes, it works
even though the header file doesn't has a definition ??

Could someone please explain the workings of the new iostream
implementation to me? Or direct me to a good text about it?

P.S. This is MS VC++ 4.2.

//Ingo
mailto:ingo@blank.pages.de
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: clamage@pacific-88.Eng.Sun.COM (Steve Clamage)
Date: 1996/08/21
Raw View
In article 5C75@identity.de, Ingo Luetkebohle <Ingo@identity.de> writes:
>I was used to the older iostream implementation and when I set out to
>use the new one, I was really puzzled. There's no "real" class in these
>headers -- just templates. Yet, if I use the standard classes, it works
>even though the header file doesn't has a definition ??

Normally the C++ vendor will provide an instantiation of the
templates on the char type and wchar type and put them in the
run-time library.

The name "ifstream", for example, is a typedef for
 basic_ifstream<char, char_traits<char> >
The C++ runtime library will contain a complete precompiled
set of functions and necessary objects for that type. When
you write
 ifstream infile("myfile.txt");
the compiler treats it as
 basic_ifstream<char, char_traits<char> > infile("myfile.txt");

At program link time, the linker finds the necessary functions and
objects in the library and does not need to generate any template code.

The template implemenation code will reside in some standard location
known to the compiler. If you need to instantiate a stream on some
type of your own (not a job for the faint of heart), it finds the
template source code and generates whatever is needed.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]