Ropes I Know

July 21, 2008

That pile of shit again …

Filed under: Computer, Programming Languages — Tags: , , — Yeti @ 23:54

This post is in reference to the “Visual C++ Team Blog

Just a short quote as a teaser:

At first glance it does appear that the user is correct – but looks can be deceiving. Just because the string class has a converting-constructor from a string-literal doesn’t mean that the compiler has to use it. For the first argument to the function call, the conversion is straight forward – both of the candidate functions expect a string and so the compiler will use the provided converting constructor to convert the string-literal to an instance of the string class. The second argument is not so straight forward. For the first function the compiler can again use the converting-constructor, but for the second function it can use the standard pointer-to-bool conversion to convert the string-literal (which the compiler will consider as type “const char*”) to bool. As this is a standard conversion, the C++ Standard considers this conversion to be cheaper than calling the converting-constructor (which is a user-defined conversion) and hence the second function is a better match than the first function and the compiler, correctly, calls that function.

No need for me to comment on this. ’nuff said.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: