December 2001
Intermediate to advanced
304 pages
6h 25m
English
Difficulty: 7
“What's in a (type) name?” Here's an exercise that demonstrates why and how to use typename, using an idiom that's common in the standard library.
What is typename, and what does it do?
What, if anything, is wrong with the code below?
template<typename T>
class X_base
{
public:
typedef T instantiated_type;
};
template<typename A, typename B>
class X : public X_base<B>
{
public:
bool operator()( const instantiated_type& i ) const
{
return i != instantiated_type();
}
// ... more stuff ...
};
1. What is typename, and what does it do?
This gets us back into the field of name lookup. A motivating example is dependent ...
Read now
Unlock full access