BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

String/bool Builder 5/6 difference

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Apr 25, 2007 5:15 pm    Post subject: String/bool Builder 5/6 difference Reply with quote



I'm seeing a difference in how overload resolution works between C++
Builder 5 and Builder 6 which is causing an issue with several
applications I need to upgrade.

I created a simple console app below and used the debugger to watch
which function is called/which one gets compiled out.
//---------------------------------------------------------------------------

#pragma hdrstop
#include <string>

using namespace std;

bool ExecuteThis(string Test){
return false;
}

bool ExecuteThis(bool Test){
return true;
}

#pragma argsused
int main(int argc, char* argv[])
{
ExecuteThis("asdfasdf");
return 0;
}
/---------------------------------------------------------------------------
Under Builder 5, the string version of ExecuteThis gets called unless
the string function does not exist. In which case, the string version
is called.
Under Builder 6 (using both the old RogueWave and new string template)
the bool version of ExecuteThis gets called, unless the bool version
does not exist. In which case, the string version is called.

Is there a setting somewhere to make the Builder 6 compiler overload
resolution behave like the Builder 5 compiler under this scenario so
it always considers the string function the better candidate than the
bool version like it did in Builder 5? I have a substantial amount of
code that expects the implicit string conversion to occur like this.
Thanks!
Back to top
Zara
Guest





PostPosted: Thu Apr 26, 2007 8:10 am    Post subject: Re: String/bool Builder 5/6 difference Reply with quote



On 25 Apr 2007 05:15:24 -0700, megatillo (AT) hotmail (DOT) com wrote:

Quote:
I'm seeing a difference in how overload resolution works between C++
Builder 5 and Builder 6 which is causing an issue with several
applications I need to upgrade.

<...>
Quote:

Is there a setting somewhere to make the Builder 6 compiler overload
resolution behave like the Builder 5 compiler under this scenario so
it always considers the string function the better candidate than the
bool version like it did in Builder 5? I have a substantial amount of
code that expects the implicit string conversion to occur like this.
Thanks!


The problem comes from the C++ standard being enforced.

My preferred solution would be to create an extra overload:

bool ExecuteThis(const char * const Test){
return ExecuteThis(string(Test));
}

But that may be a lot of work!

Zara
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.