Jump to content
  • Advertisement
Sign in to follow this  
Finalspace

Why using std::string when you can create it yourself...

This topic is 1377 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

Man, I was all set to come in here and go "WHYYYYYY would you do that?!", before I realized, wait, this is Coding Horrors.

Share this post


Link to post
Share on other sites

I love it.  But why only one kind of custom string?  

 

You need one version that uses custom memory managers. You need another version that stores the string inside what would normally be the pointer if the string is small, you need a copy-on-write version, and you need a container-like string that is backed by a temporary file on disk or network rather than kept in memory all the time.

 

Seems like every major library includes their own variations of the string. 

Share this post


Link to post
Share on other sites

This is the reason why my rendering demo was crashing all the time, when it was rendering text based of this "nice" string implementation biggrin.png

 

I think i was at a brink to just forcing myself to write everything myself... for learning purposes...

 

 

Or a single template version that does all those variations based on policy classes.

 
Templates you say.... at the time, i had no f...... glue what templates are - it was that magic voodoo stuff biggrin.png
Edited by Finalspace

Share this post


Link to post
Share on other sites

I love it.  But why only one kind of custom string?  

 

You need one version that uses custom memory managers. You need another version that stores the string inside what would normally be the pointer if the string is small, you need a copy-on-write version, and you need a container-like string that is backed by a temporary file on disk or network rather than kept in memory all the time.

 

Seems like every major library includes their own variations of the string. 

 

Don't forget the variant that only gets used when the string comes from the localization table. Oh, and all the variants are actually in the same class despite the fact that their behavior is subtly different, and you can only know which is which by looking not only at the place where any particular string was initialized, but ALSO looking in the localization table to determine if that string is defined properly for that particular language.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!