templates in code

T

Taras_96

Hi everyone,

I found the following piece of code on the net and just wanted to
check whether I understood it correctly:

std::transform( s.begin(), s.end(), s.begin(),
std::bind1st( std::mem_fun( &std::ctype<char>::tolower ),
&std::use_facet< std::ctype<char> >( loc ) ) );

ctype<char>: is this implying that ctype is a templated class?

so std::ctype<char>::tolower translates to:

the tolower member function of the ctype<char> class in the std name
space?

also:

std::use_facet< std::ctype<char> >( loc )

it seems that the type of the return argument for use_facet has been
explicitly specified by <std::ctype<char> > - is this correct? Again,
is std::ctype<char> referencing a char instance of the ctype templated
class?

It seems that this is correct when the definition of the use_facet
function is inspected:

template <class Facet>
Facet const& use_facet(locale const& loc);

Thanks

Taras
 
V

Victor Bazarov

Taras_96 said:
I found the following piece of code on the net and just wanted to
check whether I understood it correctly:

std::transform( s.begin(), s.end(), s.begin(),
std::bind1st( std::mem_fun( &std::ctype<char>::tolower ),
&std::use_facet< std::ctype<char> >( loc ) ) );

ctype<char>: is this implying that ctype is a templated class?
Yes.


so std::ctype<char>::tolower translates to:

the tolower member function of the ctype<char> class in the std name
space?
Yes.

also:

std::use_facet< std::ctype<char> >( loc )

it seems that the type of the return argument for use_facet has been
explicitly specified by <std::ctype<char> > - is this correct?
Yes.

Again,
is std::ctype<char> referencing a char instance of the ctype templated
class?

I don't think the expression "a char instance of" is idiomatic, but it
is not completely incomprehensible. And, again, yes.
It seems that this is correct when the definition of the use_facet
function is inspected:

template <class Facet>
Facet const& use_facet(locale const& loc);

I believe you've got it right.

V
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top