lundi 5 janvier 2015

Template factory function with additional args: friendship issue

I'm working on a piece of code that looks like this:



template<typename T>
class A {
// makeA should become a friend
A() {}
};

template<typename T, typename U>
A<T> makeA(const U & u) {
(void) u;
return A<T>();
}

int main() {
makeA<double>(3);
return 0;
}


But I cannot let makeA become a friend of A. Is this possible? What is the right syntax?


Aucun commentaire:

Enregistrer un commentaire