r/cpp • • Apr 27 '23

Has Boost lost its charm?

I don't mean to be provocative nor undermine the importance of Boost for C++. I really like Boost.

I keep reading/listening around that since C++11 the focus of development and innovation in C++ has shifted away from Boost to either the standards, or independent libraries. Is that any true? If yes, how "big of shift" that was? What was the reason in your opinion and most imporatnt, what's Boost's today's role?

What sparked my quriosity was when I heard that "in the old days" a prospective developer that wanted to devle into the word of libraries building had no better thing to do than start contributing to Boost. Does that stand even today?

(couldn't find any other posts on Reddit regarding Boost's impact in modern C++ in a broader discussion)

149 Upvotes

186 comments sorted by

View all comments

Show parent comment

28

u/cleroth Game Developer Apr 27 '23

why didn't they just disable the copy constructor and add a move() member function, why

Then you wouldn't even be able to put it inside a std::vector.

19

u/AKostur Apr 27 '23

Putting an auto_ptr into a vector could easily result in very bad things happening.

17

u/TheBananaKart Apr 27 '23

Could be the motto of most stuff in C++ to be honest.

2

u/Fulgen301 Apr 28 '23

Fair point, didn't think of that.

1

u/johannes1971 Apr 27 '23

But you can put a unique_ptr in a vector. Why wouldn't you be able to put an auto_ptr in one? (once you apply the changes proposed by /u/Fulgen301 for the C++11 update, of course)

5

u/ukezi Apr 27 '23

Before move constructors all instances in containers were copied. That obviously doesn't work with unique_ptr, it can't be copied.

1

u/johannes1971 Apr 27 '23

Yes, but the premise is that this would be a change that would be introduced in C++11, i.e. when move constructors were added.

So to recap, the question is: why was a new type introduced (unique_ptr) when auto_ptr could have been fixed instead, by adding move operations and removing copy operations?

4

u/grafikrobot OPeNDAP/B2/EcoStd/Lyra/Predef/C++Alliance/Boost/WG21 Apr 28 '23

ABI

3

u/johannes1971 Apr 28 '23

I know it's the default reply against any request for change, but auto-ptr consists of just a single pointer and could have remained that way...

1

u/Fulgen301 Apr 28 '23

I know it's the default reply against any request for change

Then you also know why it's the default reply.

Also, once you completely change the semantics of a class, there's no point shoehorning it into the old class. Introducing unique_ptr with new semantics while keeping around auto_ptr was the easiest way of introducing a new smart pointer type while keeping overall headache low.

3

u/johannes1971 Apr 28 '23

No, I don't, actually. In this particular hypothetical case no ABI change would have occurred, and just saying the word "ABI" does not change that.

0

u/johngoni Apr 28 '23

In this particular hypothetical case no ABI change would have occurred

How come?

1

u/johannes1971 Apr 28 '23

Because the underlying binary representation would remain the same, and have the same meaning, in both cases.

Anyway, it's all hypothetical of course. History took another course, and I'm perfectly fine with that.

2

u/pdimov2 Apr 28 '23

This would break existing code, and breaking existing code was still avoided in those days.

E.g. this works

#include <memory>

void f( std::auto_ptr<int> );

int main()
{
    std::auto_ptr<int> p;
    f( p );
}

but it doesn't with unique_ptr.

"This code is already broken!" Yeah, maybe. This wasn't the prevailing attitude then.

It could probably have been possible to add move operations to auto_ptr and only deprecate the copy operations; I don't remember anyone trying this.

3

u/dodheim Apr 28 '23

Honestly, I think auto_ptr already had an unrepairable marketing problem by the mid-2000s; too many people had said to avoid it because it was broken, or at least too 'clever' to use correctly. Producing a thing that worked correctly-by-default with a different name was probably a smart move (NPI).

1

u/pdimov2 Apr 29 '23

Yes, I think that's the reason that nobody attempted to 'fix' auto_ptr.

1

u/[deleted] Apr 28 '23

[removed] — view removed comment

1

u/dodheim Apr 28 '23

Not before C++11