Code dependent on template argument?

Hi,

I have a template function and I want it to do something only when its template argument is say == class Date. How can I accomplish that?

Sample:

template<typename Control>
void doStuff() {

///..... do a lot here

if( Control == Date ) {
//// do only if Control is Date
}

}

Thanks,
Juan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template < typename T > struct do_more_stuff
{
    static void do_date_specific_stuff() { /* do nothing */ }
};

template <> struct do_more_stuff<Date>
{
    static void do_date_specific_stuff() { /* do date specific things */ }
};

template < typename Control > void do_stuff()
{
    //..... do a lot here

    do_more_stuff<Control>::do_date_specific_stuff() ;
}
great!! thanks!!!
Topic archived. No new replies allowed.