str->begin()
Then again, it's very rare that you'll allocate std::string on a heap. The whole point of standard containers is that you allocate them on stack, so that compiler takes care of entire memory management.
class foo {public: foo() {} // no explicit construction foo(const std::string & s1, const std::string & s2) : str1(s1) , str2(s2) {} foo(const char * s1, const char * s2) : str1(s1) , str2(s2) {} // no destructor, not neededprivate: std::string str1; std::string str2;};int main() { foo f1; // f1 has two usable strings foo f2("Hello", "World"); // str1 and str2 are initialized to s1 and s2 return 0;} // f1 and f2 and its strings are properly de-allocated
Quote:I've done some searches on basic_string and all I come up with is the functions templates so I'm assuming no body actually uses it.
Everyone who uses std::string uses it. std::string is a typedefed std::basic_string< char, std::char_traits<char>, std::allocator<char> > (or close to that)
basic_string is used for template programming.
// accepts std::string, std::wstring or any variation of them,// using any allocatortemplate < class C, class T, class A >void foo( const std::basic_string<C, T, A> & s ){ // do foo on s};
This is compile-time polymorphism, where you can pass any string type, but each type will be treated individually