[C++ Template]what is the type of instantiation of template function.

The book <<C++ templates>> said:
[C++ Template]what is the type of instantiation of template function._第1张图片

however, in VS2008 and gcc 4.3, the compilers can deduce the type of parameter. The followed code has no compile error.
look here( http://ideone.com/yTpaJ ) for gcc result.
#include   <vector>
#include   <algorithm>
using   namespace   std;
template   < typename   T,   int   VAL>
T addValue (T   const & x) {
      return   x + VAL;
}
int   main( int   argc,   char * argv[])
{
      vector< int > source;
      vector< int > dest;
       int   (*funP)( int   const &);
      funP = addValue< int ,5>;
      std::transform (source.begin(), source.end(),    // start and end of source
                dest.begin(),                    // start of destination
                addValue< int ,5>);                // operation

      std::transform (source.begin(), source.end(),    // start and end of source
                dest.begin(),                    // start of destination
                funP);  
       return   0;
}

你可能感兴趣的:(function)