Re[2]: Выбор конструктора
От: vi.k  
Дата: 31.08.10 05:26
Оценка:
Здравствуйте, night beast, Вы писали:

NB>Здравствуйте, vi.k, Вы писали:


VK>>Компилятор (gcc 4.4.4, Feodora) в этом случае выбирает вариант 2.

VK>>Выходит, что для него логичнее преобразовать const wchar_t * к bool, чем к const std::wstring?

VK>>Есть какие-то объяснения этому?


NB>C++ Templates: The Complete Guide

NB>By David Vandevoorde, Nicolai M. Josuttis

NB>

NB>Given this first principle, we are left with specifying how well a given argument matches the corresponding parameter of a viable candidate. As a first approximation we can rank the possible matches as follows (from best to worst):

NB>* Perfect match. The parameter has the type of the expression, or it has a type that is a reference to the type of the expression (possibly with added const and/or volatile qualifiers).

NB>* Match with minor adjustments. This includes, for example, the decay of an array variable to a pointer to its first element, or the addition of const to match an argument of type int** to a parameter of type int const* const*.

NB>* Match with promotion. Promotion is a kind of implicit conversion that includes the conversion of small integral types (such as bool, char, short, and sometimes enumerations) to int, unsigned int, long or unsigned long, and the conversion of float to double.

NB>* Match with standard conversions only. This includes any sort of standard conversion (such as int to float) but excludes the implicit call to a conversion operator or a converting constructor.

NB>Match with user-defined conversions. This allows any kind of implicit conversion.

NB>Match with ellipsis. An ellipsis parameter can match almost any type (but non-POD class types result in undefined behavior).



Какой вариант мой? С моим плохим английским, мне кажется, что оба случая попадают в последнюю группу. Но тогда как он разделяет дальше?
Или же преобразование указателя к bool является standard conversions?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.