mardi 28 juin 2016

How to create alias to template method

From this link (1056. Template aliases, member definitions, and the current instantiation) I realised that, We can create alias in templates, for example we could do as below

template<typename T>
using Vec = std::vector<int>

How can I create alias for a template method, I tried below but it throws compilation error error: missing template arguments before '.' token

#include <iostream>
using namespace std;

template <class T> struct A 
{
    float g(T x){return(x*0.01);}
};

template <class T> using B = A<T>;

int main() 
{
    B.g<int>(10);
    // your code goes here
    return 0;
}

I'm not sure how to create alias for template method, Please someone shed light on this.

Aucun commentaire:

Enregistrer un commentaire