خرید بک لینک

Vote count: 0

Is this a proper restriction on overloading behavior. I can't figure out how to replicate a similar issue in pure C++ to compare behavior.

C++/CLI code:

class A {};

List<int>^ g(A &) {
    retu gcnew List<int>();
}

template<typename T>
List<T>^ g(T &) {
    retu gcnew List<T>();
}

void f() {
    g(A()); // compiler error C3235
}

Generates:

error C3225: generic type argument for 'T' caot be 'A', it must be a value type or a handle to a reference type

The problem appears to be from the retu values. It's requiring that the templated g() has a valid definition even though the non-templated g() overload is going to be selected.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 13 تير 1395 ساعت: 6:39

صفحه بندی