mcc ,
@mcc@mastodon.social avatar

Absurd C++ question. Say i do this:

std::string *str = get_pointer();

*str = string("Something");

If I'm not totally confused, that second line will do two things. It will call ~std::string() on *str, then it will assign the new string "something" to *str.

Is there a way to opt out of that ~? Say I really need, never mind if it's a good idea I just need, to store a str in a buffer created outside C++. When I'm done with it I'll call the destructor by hand. How do I initially populate it?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • test
  • worldmews
  • mews
  • All magazines