Item 5. Typename

I l @ ve RuBoard

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.

  1. What is typename , and what does it do?

  2. 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 ... }; 
I l @ ve RuBoard


More Exceptional C++
More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
ISBN: 020170434X
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Herb Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net