impala-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Apple <>
Subject Re: scoped_ptr -> unique_ptr?
Date Wed, 31 Aug 2016 18:16:12 GMT
Why should we reduce our boost dependency?

Do you think there are places where scoped_ptr is used now where you
would want to keep it indefinitely if it were part of the standard and
not part of boost?

On Wed, Aug 31, 2016 at 10:47 AM, Henry Robinson <> wrote:
> We use boost::scoped_ptr everywhere to handle scope-owned heap-allocated
> objects. C++11 has std::unique_ptr for this. I'd like to get a decision on
> whether we should start standardising on unique_ptr. This is particularly
> relevant for new code - should I call it out in code review?
> The most significant difference is that unique_ptr is moveable, which means
> it can be used in collections (good!). It also means that badly written
> code can allow scope-owned objects to escape their scope:
> private:
>   unique_ptr<Foo> foo_;
> public:
>   unique_ptr<Foo> get_foo() { return move(foo_); }
> or worse:
>   Foo* get_foo() { return foo_.release(); }
> In both cases you have to be quite explicit about the decision to yield
> ownership of the owned object, and it seems to me that we should catch this
> in code review.
> Since using unique_ptr in collections is so useful, and reducing our boost
> dependency is generally worthwhile, I'm very much in favour of moving to
> unique_ptr for future code, and at some point porting all the current
> scoped_ptr to unique_ptr.
> What do you think?
> Henry

View raw message