View Single Post
Old Apr 6th, 2007, 7:41 AM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
A longer explanation can be found by referring to the C++ standard:
Quote:
4.2 Array-to-pointer conversion [conv.array]

1 An lvalue of type "array of N T" or "array of unknown bound of T" can
be converted to an rvalue of type "pointer to T." The result is a
pointer to the first element of the array.

2 A string literal (_lex.string_) that is not a wide string literal can
be converted to an rvalue of type "pointer to char"; a wide string
literal can be converted to an rvalue of type "pointer to wchar_t".
In either case, the result is a pointer to the first element of the
array. [Note: this conversion is deprecated. See Annex _depr_. ]
For the purpose of ranking in overload resolution (_over.ics.scs_),
The equivalency of the two, under some conditions, is due to a conversion, not an identity. You can see this clearly if you write the relevant code and examine the emitted machine code. This is akin to an integer being converted or promoted to a double, without a cast, if you write the code correctly.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote