template, implicit specialization?

G

Guest

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
 
P

persenaama

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.
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top