Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6680
| From | ruben safir <ruben@mrbrklyn.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: base_ostream template arguments |
| Date | 2011-06-13 06:38 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <it4b8r$moe$3@reader1.panix.com> (permalink) |
| References | <it44cp$ioc$5@reader1.panix.com> <3b3ff35c-2d57-4f96-a5dc-8a46b0aa15f7@a31g2000vbt.googlegroups.com> |
On Sun, 12 Jun 2011 22:18:03 -0700, Öö Tiib wrote:
> On Jun 13, 7:40 am, ruben safir <ru...@mrbrklyn.com> wrote:
>> The base_ostream template is defined as follows (according to
>> Struostrup)
>>
>> template<class Ch, class Tr = char_traits<Ch> > class
>> std::basic_ostream : virtual public basic_ios<Ch, Tr > { 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<Ch>, it is default defined as
> char_traits<Ch>. 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 <class Ch, class TR = char_traits<Ch> >
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
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
base_ostream template arguments ruben safir <ruben@mrbrklyn.com> - 2011-06-13 04:40 +0000
Re: base_ostream template arguments Öö Tiib <ootiib@hot.ee> - 2011-06-12 22:18 -0700
Re: base_ostream template arguments ruben safir <ruben@mrbrklyn.com> - 2011-06-13 06:08 +0000
Re: base_ostream template arguments ruben safir <ruben@mrbrklyn.com> - 2011-06-13 06:38 +0000
Re: base_ostream template arguments Öö Tiib <ootiib@hot.ee> - 2011-06-13 01:45 -0700
Re: base_ostream template arguments Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-12 23:14 -0700
Re: base_ostream template arguments ruben safir <ruben@mrbrklyn.com> - 2011-06-13 06:32 +0000
Re: base_ostream template arguments Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-13 00:08 -0700
Re: base_ostream template arguments ruben safir <ruben@mrbrklyn.com> - 2011-06-13 03:17 -0400
Re: base_ostream template arguments mrbrklyn <ceo.brooklyn@gmail.com> - 2011-06-13 12:45 -0700
csiph-web