Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!transit3.readnews.com!news-out.readnews.com!transit4.readnews.com!panix!not-for-mail From: ruben safir Newsgroups: comp.lang.c++ Subject: Re: base_ostream template arguments Date: Mon, 13 Jun 2011 06:38:19 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 46 Message-ID: References: <3b3ff35c-2d57-4f96-a5dc-8a46b0aa15f7@a31g2000vbt.googlegroups.com> NNTP-Posting-Host: www2.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader1.panix.com 1307947099 23310 96.57.23.82 (13 Jun 2011 06:38:19 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Mon, 13 Jun 2011 06:38:19 +0000 (UTC) User-Agent: Pan/0.133 (House of Butterflies) Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:6680 On Sun, 12 Jun 2011 22:18:03 -0700, Öö Tiib wrote: > On Jun 13, 7:40 am, ruben safir wrote: >> The base_ostream template is defined as follows (according to >> Struostrup) >> >> template > class >> std::basic_ostream : virtual public basic_ios { public: >>         virtual ~basic_ostream(); >> //... >> >> }; >> >> since Tr is always defined as a function of Ch, why was it necessary >> for two template parameters? > > Tr is not always defined as char_traits, it is default defined as > char_traits. You can put there your own custom-made traits as second > template argument. It's very interesting. The very next template is for basic_ios which Strousup defines as this template > public: typedef Ch char_type; typedef Tr traits_type; typedef typename Tr::int_type int_type; typedef typename Tr::pos_type pos_type; typedef typename Tr::off_type off_type; }; It also defaults to the same type. But what i find interesting and new is the last 3 typedef's typedef typename Tr::int_type int_type; typedef typename Tr::pos_type pos_type; typedef typename Tr::off_type off_type; There is no explanation to how any of these would be used and I've never seen the keyword typename used outside of <>. How does that work? Ruben