The boost C++ library is a famous sandbox for the language and Standard Library features that absorbed with each new version of the Standard C++. However boost components that eventually became a part of the Standard are still present in boost. One of the classic examples of said above are smart pointers. So why do I need Boost.SmartPtr
for the C++ compiler that supports C++11 and later?
Asked
Active
Viewed 60 times
1

nickolay
- 3,643
- 3
- 32
- 40
-
2People use Boost in production code so maintaining compatibility is a goal (of Boost). – Richard Critten Nov 25 '21 at 10:34
-
2Even the things that were absorbed still continue to evolve in boost (something the standard cannot permit to happen as rapidly). For example, `boost::enable_shared_from` is a type erasing alternative to `enable_shared_from_this`. – StoryTeller - Unslander Monica Nov 25 '21 at 12:13
-
@RichardCritten this is a good point I agree with it. – nickolay Nov 25 '21 at 15:15
-
@StoryTeller-UnslanderMonica that's a valuable point! also thought about it but did not have a good example – nickolay Nov 25 '21 at 15:15
-
Also interesting is the more general question https://stackoverflow.com/questions/8851670/which-boost-features-overlap-with-c11 – sehe Nov 25 '21 at 15:58
1 Answers
4
Why do I need Boost.SmartPtr for the C++ compiler that supports C++11 and later?
Because:
- You may need your program to compile with another compiler that doesn't support C++11 or later.
- You may not want to bother implementing
make_unique
yourself. Sure it's easy, but why do it when you can use an existing implementation? - You may want to use one of the smart pointers provided by Boost.SmartPtr besides shared pointer.
- You may already have been using it, and don't want to pay for the effort of stopping using it.

eerorika
- 232,697
- 12
- 197
- 326
-
just for the reference to future readers `make_unique` is implemented in standard C++ starting from C++14 – nickolay Nov 25 '21 at 15:20
-
-
@nickolay See the list of smart pointers in the documentation of Boost.SmartPtr. – eerorika Nov 25 '21 at 15:21
-
thanks I understand that. Just thought you have a real world example on your fingertips. Such examples are always teaching! – nickolay Nov 27 '21 at 22:02