Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design

Explicit Template Argument Specification

One of the newer features in C++ is the ability to explicitly specify argument types for function templates. As a simple example of this, consider the following:

template <class T> void f(int i) { T x = i; ... } void g() { f<double>(37); }

It used to be that you'd have to use all the template parameter types (like T) in the declaration of the template, but this is no longer required. In this example, T is declared via the <> specification to be of type double, and the actual function parameter is of course an int.

One possible application for the feature is the ability to specify what a template's return type should be:

template <class T, class U, class V> V max(T t, U u) { if (t > u) return V(t); else return V(u); } void g() { int i = max<double,double,int>(12.34, 43.21); }

independent of reliance on the template function arguments.

 

India seo freelance web designer India web development ecommerce website developer India
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100