Re[9]: this const
От: Артур Россия  
Дата: 10.04.03 14:55
Оценка: 18 (2)
Здравствуйте, Михаил Трухманов, Вы писали:



МТ>Новая формулировка: есть предположение, что foo(int*) и foo(int* const) -- одно и то же, потому что

МТ>1.кажется бессмысленным указывать const по значению
МТ>2.VC6 генерит одни и те же имена


Пожалуй ты прав:
ansi_iso_iec_14882-1998 8.3.5 Functions пункт 3:

The type of a function is determined using the following rules. The type of each parameter is determined from its own declspecifierseq and declarator. After determining the type of each parameter, any parameter of type “array of T” or “function returning T” is adjusted to be “pointer to T” or “pointer to function returning T,” respectively. After producing the list of parameter types, several transformations take place upon these types to determine the function type. Any cvqualifier modifying a parameter type is deleted . [Example: the type void(*)(const int) becomes void(*)(int) —end example] Such cvqualifiers affect only the definition of the parameter within the body of the function; they do not affect the function type.

... << RSDN@Home 1.0 beta 6a >>
Re[10]: this const
От: Михаил Трухманов Россия  
Дата: 10.04.03 16:05
Оценка:
Здравствуйте, Артур, Вы писали:

МТ>Новая формулировка: есть предположение, что foo(int*) и foo(int* const) -- одно и то же, потому что

МТ>1.кажется бессмысленным указывать const по значению
МТ>2.VC6 генерит одни и те же имена

А>Пожалуй ты прав:

Any cvqualifier modifying a parameter type is deleted . [Example: the type void(*)(const int) becomes void(*)(int) —end example] Such cvqualifiers affect only the definition of the parameter within the body of the function; they do not affect the function type.


Жалко, у меня нет навыка искать в стандарте
Но, в принципе, это не совсем "одно и то же" отличие есть -- для "the body of the function". Мы тут рядом с Дмитрием Наумовым на эту тему беседуем
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.