views:

169

answers:

3

I'm looking for independent implementation of boost/tr1 shared_ptr, weak_ptr and enable_shared_from_this.

I need:

  • Boost independent very small implementation of these features.
  • I need support of only modern compilers like GCC-4.x, MSVC-2008, Intel not things like MSVC6 or gcc-3.3
  • I need it to be licensed under non-copyleft LGPL compatible license like Boost/Mit/3-clause BSD.

So I can include it in my library.

Note - it is quite hard to extract shared_ptr from boost, at least BCP gives about 324 files...

+1  A: 

Recent versions of GCC include an implementation of TR1.

#include <tr1/memory>

This gives you all three things you mention, in the std::tr1 namespace.

Thomas
-1 The OP want a portable version working on GCC-4.x, MSVC-2008, Intel As some version of these compiler don't provide this file he needed boost/tr1.
Vicente Botet Escriba
@Vicente where is that -1 you said you casted?
Johannes Schaub - litb
I meant that the answer doesn't respond to the question.
Vicente Botet Escriba
+2  A: 

I extracted shared_ptr from Boost to use it separately, and it was definitely fewer than 300 files. That was 3 years ago however so things may have changed (maybe there are more files in the config folder these days?). What I needed for the shared_ptr was:

  • assert.hpp
  • checked_delete.hpp
  • throw_exception.hpp
  • config.hpp and config directory
  • detail/bad_weak_ptr.hpp
  • detail/interlocked.hpp
  • detail/shared_count.hpp
  • detail/sp_counted_base.hpp
  • detail/sp_counted_base_w32.hpp
  • detail/sp_counted_impl.hpp
  • detail/workaround.hpp
  • and finally, shared_ptr.hpp itself.

I don't think weak_ptr and enable_shared_from_this will add a lot of files to that.

Alex - Aotea Studios
+1  A: 

BCP work at the component level, so any dependency between components result in an explosion of the number of files.

I would try to include the files that I need an those that the compiler tell me that are not found, one by one. When your product is build you should have the needed files.

This should reduce a lot the number of files, at the expenses of some of your time.

It would be clearly a must if BCP was able to do this for you: worked at the file level and not at the component level, and was able to take care of conditional compilation.

Vicente Botet Escriba