Boost logo

Boost :

Subject: [boost] unique_ptr for C++03
From: Andrew Ho (helloworld922_at_[hidden])
Date: 2013-08-03 05:00:28


I implemented std::unique_ptr using C++03 features plus a few other Boost
Libraries. Incidentally, I also implemented default_delete (which binds to
std::default_delete if available) because it's required for unique_ptr.

The library binds to std::unique_ptr if standard library support is

There are a few things I don't think I'll be able to emulate exactly.


- I don't think the deleter can ever be forwarded correctly (limitation of
C++03). Ideas/suggestions for how to best handle this are welcome
(currently, I move the deleter if E == D and copy otherwise, I think)

- There's no explicit conversion overloads in C++03. Currently I have
operator bool() implemented non-explicitly if there's no compiler support,
relying on the user to only use it "as-if explicit". An alternative solution
is to remove the typecast operator and force users to use get() ==

- functions relying on nullptr_t are only enabled if compiler support is
available. Again, I don't think there's any possible work-around for C++03.

There are also a few missing features (still working on the implementation):

- make_unique (part of c++14)
- nullptr_t comparison operators

Current dependencies (assuming no C++11 std::unique_ptr):

- Boost.Config
- Boost.Move
- Boost.TypeTraits

Comments/Feedback is welcome.

Boost list run by bdawes at, gregod at, cpdaniel at, john at