1

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?

nickolay
  • 3,643
  • 3
  • 32
  • 40
  • 2
    People use Boost in production code so maintaining compatibility is a goal (of Boost). – Richard Critten Nov 25 '21 at 10:34
  • 2
    Even 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 Answers1

4

Why do I need Boost.SmartPtr for the C++ compiler that supports C++11 and later?

Because:

  1. You may need your program to compile with another compiler that doesn't support C++11 or later.
  2. 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?
  3. You may want to use one of the smart pointers provided by Boost.SmartPtr besides shared pointer.
  4. 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