Friday, February 20, 2009

std::string

I was reading the Daily WTF (which is can be a great learning resource on the potential horrors of any programming language and development system).

I saw the most incredible claim, "C/C++ has no native support for such a structure [strings]. It's only in the STL.".

Err, yea, it's hard to do C++ nowadays without the STL.

You might think this code won't work:

std::string arg("Hi me");
if( "Hi me" == arg ) { printf("Yup"); }


But it resolves to
operator==(const char*, std::string &);


Of course it leads to the horror I have to deal with:

Ret myFun(const char *charp)
{
FX::FXString foxStr(charp);
randomFoxFun(&foxStr);

std::string stlStr(foxStr.text());
randomStlFun(&stlStr);

// convert STL string to Fox String
// convert STL string to char*
}

No comments: