Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > template, implicit specialization?

Reply
Thread Tools

template, implicit specialization?

 
 
Guest
Posts: n/a
 
      09-18-2005
Hi everyone, I've got this pice of code:

template <bool cond, typename A, typename B>
struct Select{
typedef A Result;
};

template <typename A, typename B>
struct Select<false, A, B>{
typedef B Result;
};

Select<false, char, float>::Result temp;

What is the second template supposed to be? An implicit specialization? It's
not an explicit one for sure.
If anyone could explain me what happens ...it would be great. thanx


 
Reply With Quote
 
 
 
 
persenaama
Guest
Posts: n/a
 
      09-18-2005
> What is the second template supposed to be?

A partial specialization.

> If anyone could explain me what happens ...it would be great. thanx


What happens is that Select<false,char,float>::Result is float. For
such trivial example it is equivalent of:

float temp;

The usefulness of such contruct becomes more apparent in more complex
programs.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Implicit localization Progman ASP .Net 2 03-02-2006 08:06 PM
Implicit rule PIX Nieuws Xs4all Cisco 3 11-30-2005 02:14 AM
Implicit object creation RHC Java 3 11-10-2004 09:22 AM
Passing implicit (standard) "config" object from jsp to java class (not servlet) cvelusc Java 5 06-03-2004 04:14 PM
Question on additional decimals in implicit conversion Jacob Java 7 10-03-2003 10:23 PM



Advertisments