vendredi 27 octobre 2017

Overload selection between pointer and reference for double argument when passing 0 literal

Consider the following two overloads:

template <T> void foo(T * d);
template <T> void foo(const T & d);

If used like this:

foo<double>(0);

Which overload will be called? Can you please point-me at the spec paragraph that define this behavior?

ps: From some quick tests it seems that the literal zero matches the nullptr, therefore the pointer overload is selected, but I'd like to know from the language spec.

Aucun commentaire:

Enregistrer un commentaire