Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6671 > unrolled thread

base_ostream template arguments

Started byruben safir <ruben@mrbrklyn.com>
First post2011-06-13 04:40 +0000
Last post2011-06-13 12:45 -0700
Articles 10 — 4 participants

Back to article view | Back to comp.lang.c++


Contents

  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

#6671 — base_ostream template arguments

Fromruben safir <ruben@mrbrklyn.com>
Date2011-06-13 04:40 +0000
Subjectbase_ostream template arguments
Message-ID<it44cp$ioc$5@reader1.panix.com>
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?

Ruben

[toc] | [next] | [standalone]


#6674

FromÖö Tiib <ootiib@hot.ee>
Date2011-06-12 22:18 -0700
Message-ID<3b3ff35c-2d57-4f96-a5dc-8a46b0aa15f7@a31g2000vbt.googlegroups.com>
In reply to#6671
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.

[toc] | [prev] | [next] | [standalone]


#6675

Fromruben safir <ruben@mrbrklyn.com>
Date2011-06-13 06:08 +0000
Message-ID<it49hi$moe$1@reader1.panix.com>
In reply to#6674
On Sun, 12 Jun 2011 22:18:03 -0700, Öö Tiib wrote:


> 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.

Thanks, can you expand on that a little?  What does the char_traits 
template look like?

Ruben

[toc] | [prev] | [next] | [standalone]


#6680

Fromruben safir <ruben@mrbrklyn.com>
Date2011-06-13 06:38 +0000
Message-ID<it4b8r$moe$3@reader1.panix.com>
In reply to#6674
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

[toc] | [prev] | [next] | [standalone]


#6684

FromÖö Tiib <ootiib@hot.ee>
Date2011-06-13 01:45 -0700
Message-ID<c1da58c4-67df-4bca-8947-bd8bacbf418c@m4g2000yqk.googlegroups.com>
In reply to#6680
On Jun 13, 9:38 am, ruben safir <ru...@mrbrklyn.com> wrote:
> 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?

When there is template parameter Tr then language rules demand that
you to indicate with keyword typename that Tr::int_type is name of
nested type in Tr, not a member function of Tr. Otherwise it does not
compile.

The meaning of members and nested types in char_traits you can find in
any C++ library reference. Take for example cplusplus.com:
http://www.cplusplus.com/reference/string/char_traits/

[toc] | [prev] | [next] | [standalone]


#6676

FromSaeed Amrollahi <amrollahi.saeed@gmail.com>
Date2011-06-12 23:14 -0700
Message-ID<44e5179c-fb9f-40cc-b677-4a1520e82671@c41g2000yqm.googlegroups.com>
In reply to#6671
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?
>
> Ruben

Hi
Please spell the family name of Bjarne correctly. He is Stroustrup,
not Struostrup or Stoustrup.

  -- Saeed Amrollahi

[toc] | [prev] | [next] | [standalone]


#6679

Fromruben safir <ruben@mrbrklyn.com>
Date2011-06-13 06:32 +0000
Message-ID<it4aum$moe$2@reader1.panix.com>
In reply to#6676
On Sun, 12 Jun 2011 23:14:16 -0700, Saeed Amrollahi wrote:


> Hi
> Please spell the family name of Bjarne correctly. He is Stroustrup, not
> Struostrup or Stoustrup.
> 
>   -- Saeed Amrollahi


I'll try to keep it in mind.  Is it true that your going to defect, like 
the rumors floating around the net?  I'd be really interested in that 
story, but it would better to send off list.  Your a brave man.  Most of 
the people I know who got out did it at great peril to their families.

Ruben

[toc] | [prev] | [next] | [standalone]


#6681

FromSaeed Amrollahi <amrollahi.saeed@gmail.com>
Date2011-06-13 00:08 -0700
Message-ID<1fcf125d-dff8-41cb-b09b-8700170abbcc@b21g2000yqc.googlegroups.com>
In reply to#6679
On Jun 13, 9:32 am, ruben safir <ru...@mrbrklyn.com> wrote:
> On Sun, 12 Jun 2011 23:14:16 -0700, Saeed Amrollahi wrote:
> > Hi
> > Please spell the family name of Bjarne correctly. He is Stroustrup, not
> > Struostrup or Stoustrup.
>
> >   -- Saeed Amrollahi
>
> I'll try to keep it in mind.  Is it true that your going to defect, like
> the rumors floating around the net?  I'd be really interested in that
> story, but it would better to send off list.  Your a brave man.  Most of
> the people I know who got out did it at great peril to their families.
>
> Ruben

What do you mean? I am a humble Iranian C++ Programmer. I'm
an advisory member of C++ standardization committee and sometimes
send posts/reply posts and learn a lot from c.l.c and c.l.c.moderated
including the posts by you.
If you would like please see the following link:
http://www.research.att.com/~bs/bs_faq.html#pronounce

 -- Saeed Amrollahi

[toc] | [prev] | [next] | [standalone]


#6682

Fromruben safir <ruben@mrbrklyn.com>
Date2011-06-13 03:17 -0400
Message-ID<it4dil$73g$1@reader1.panix.com>
In reply to#6681
On 06/13/2011 03:08 AM, Saeed Amrollahi wrote:
> On Jun 13, 9:32 am, ruben safir<ru...@mrbrklyn.com>  wrote:
>> On Sun, 12 Jun 2011 23:14:16 -0700, Saeed Amrollahi wrote:
>>> Hi
>>> Please spell the family name of Bjarne correctly. He is Stroustrup, not
>>> Struostrup or Stoustrup.
>>
>>>    -- Saeed Amrollahi
>>
>> I'll try to keep it in mind.  Is it true that your going to defect, like
>> the rumors floating around the net?  I'd be really interested in that
>> story, but it would better to send off list.  Your a brave man.  Most of
>> the people I know who got out did it at great peril to their families.
>>
>> Ruben
>
> What do you mean? I am a humble Iranian C++ Programmer. I'm
> an advisory member of C++ standardization committee and sometimes
> send posts/reply posts and learn a lot from c.l.c and c.l.c.moderated
> including the posts by you.
> If you would like please see the following link:
> http://www.research.att.com/~bs/bs_faq.html#pronounce
>
>   -- Saeed Amrollahi


Saeed, I don't really know enough C++ to learn from.  The only time you 
might learn from me about C++ is if I ask a thoughtful question which 
other more experienced programmers might give a penetrating and 
thoughtful answer.  May you always remain safe.


Reuvain

[toc] | [prev] | [next] | [standalone]


#6732

Frommrbrklyn <ceo.brooklyn@gmail.com>
Date2011-06-13 12:45 -0700
Message-ID<c3fe1850-a3d7-4fca-b105-471ce911c75a@d26g2000prn.googlegroups.com>
In reply to#6681
link:http://www.research.att.com/~bs/bs_faq.html#pronounce
>
>  -- Saeed Amrollahi

Is that really called a bs faq?  very funny (at least in asii.  can't
vouch for utf-32)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web