[ create a new paste ] login | about

Link: http://codepad.org/awGYWiWv    [ raw code | output | fork ]

C++, pasted on Nov 24:
#include <iostream>
using namespace std;

template<typename T>
void fun(const T & val)
{
   cout << " T " << endl;
}

template<>
void fun<int>(const int & val)
{
   cout << " specialization " << endl;
}

template<>
void fun<double>(const double& val)
{
   cout << " specialization same code " << endl;
}


int main()
{
    fun( 1 );
    fun( 1.0 );
    fun( 'c' );
    return 0;
}


Output:
1
2
3
 specialization 
 specialization same code 
 T 


Create a new paste based on this one


Comments: