Which instantiation is correct, i.e. should not cause a compilation error ? (Indicate all the suitable options)
template < typename R, typename A >
void F(R (A))
{
}

struct R;

struct A { operator R(); };

struct R { R(A) {} };

A::operator R()
{ return R(* this); }

R g(A a)
{
    return R(a);
}

int main()
{
    A a;
    R r(a);
    F< R, A >(a); // (1)
    F< R, A >(r); // (2)
    F< R, A >(g); // (3)
    return 0;
}
Explanation
The argument of the function :
template < typename R, typename A > void F(R (A))
has the type : R (*) (A) i.e. the type of pointer to the function

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты