IFTI with template alias fails in D, works in C++
Timothee Cour via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 12 10:08:51 PDT 2015
main.d:
----------
struct A(T, int D) {
this(string ignore){}
}
alias B(T)=A!(T, 1);
void fun1(T)(A!(T,1) a) { }
void fun2(T)(B!T a) { }
unittest{
auto a=A!(double,1)("a");
assert(is(typeof(a) == B!double));
fun1(a);//ok
fun2!double(a);//ok
// no IFTI here:
//fun2(a);//not ok:
//fun2 cannot deduce function from argument types !()(A!(double, 1)),
candidates are...
}
----------
C++ works fine here:
main.cc:
----------
template<class T, int D>
class A {
};
template <class T>
using B = A<T, 1>;
template <class T>
void fun(B<T> a) { }
void test(){
A<double,1>a;
fun(a);
}
----------
I can use a workaround but it makes the code uglier. What's the recommended
way around this?
Could we support this as in C++?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150812/06bedf79/attachment.html>
More information about the Digitalmars-d-learn
mailing list