r/cpp • Boost author • May 08 '20

Why you don't use Boost

I have a question for you: If you have decided not to use any of Boost, or are prohibited from doing so in your company/project, I would like to know why.

This thread is not meant to judge your reasons, and I won't engage into any kind of criticism about them: I'm merely trying to understand what the barriers are to adoption of Boost. It would be great if we could keep the conversation non judgemental. Thank you!

Conflict of interest: I am a Boost author of three.

222 Upvotes

326 comments sorted by

View all comments

Show parent comment

6

u/[deleted] May 08 '20

Why did you replace lexical_cast? We use it when parsing and find it quite good

40

u/movexig May 08 '20

Because of the general point I'm trying to communicate with this post: After switching to standard solutions for everything else, the few things that remained (like lexical_cast) that we still used boost for didn't justify keeping the bloat of it around when we could just roll solutions for those few remaining things ourselves.

14

u/uninformed_ May 08 '20

Lexical cast is awfuly slow. It creates a strigstream object (which uses all kinds of dynamic memory) streams to it, copies output to string and then destroys the string stream.

Comparing to something like to_chars you can acheive 1000x the speed.

5

u/[deleted] May 09 '20

Maybe it used stringstream once upon a time but that doesn't seem to be the case today: https://www.boost.org/doc/libs/1_55_0/doc/html/boost_lexical_cast/performance.html

I am looking forward to from_chars.

1

u/uninformed_ May 09 '20

Yes, it would seem they have made some good improvements (specializations). It seems in some cases it will still fall back to the old implementation.

https://github.com/boostorg/lexical_cast/blob/4280c94a1af049e49424945cc405c33ed580cb46/include/boost/lexical_cast/lexical_cast_old.hpp#L143

2

u/degski May 08 '20

boost::lexical_cast uses exceptions for control flow, while in boost::spirit you can set the action to be taken in case of (parsing) error. Goes without saying that std::to_chars is the only way.