A minimal shared/unique_ptr implementation to handle cases where boost/std::shared/unique_ptr are not available.
A minimal shared/unique_ptr implementation to handle cases where boost/std::shared/unique_ptr are not available.
shared_ptr is a minimal implementation of smart pointer, a subset of the C++11 std::shared_ptr or boost::shared_ptr.
It comes with a fake implementation of a unique_ptr for C++98.
to replace the C++11 std::shared_ptr and boost::shared_ptr where they are not available
to be a header only implementation
to keep dependencies to a minimum (STL)
to be portable
to be light (minimizing code size, presently 92 bytes per template usage)
to be fast and monothreaded (not thread-safe)
to be well documented with Doxygen tags
to have a perfect unit test coverage
to use a permissive MIT license, similar to BSD or Boost, for proprietary/commercial usage
to also provide a fake unique_ptr to be used with older compiler
does not come with a weak_ptr implementation
does not manage array type (does not call delete[] for array allocated with new[])
does not manage the underlying raw pointer type separately from the template shared_ptr type : does not call delete on the right type, thus needing virtual destructor (as with raw pointer)
does not distinguish between the stored pointer and the owned pointer : cannot store a pointer to object member while managing a pointer to the object itself
not thread-safe
the fake unique_ptr does not at all conform to the standard, and so is only a placeholder for use with older compilers
Developments and tests are done under the following OSs :
To use this shared_ptr implementation, you only need to include the shared_ptr.hpp file from the source code of your projects.
This project is continuously tested under Ubuntu Linux with the gcc and clang compilers using the Travis CI community service with the above CMake building and testing procedure.
Detailed results can be seen online: https://travis-ci.org/SRombauts/shared_ptr
Copyright (c) 2013-2014 Sébastien Rombauts ([email protected])
Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt or copy at http://opensource.org/licenses/MIT)
The Xxx class:
class Xxx
{
public:
Xxx(size_t len = 0);
~Xxx(void);
...
void doSomething(void);
...
};shared_ptr usage:
…The most efficient way to help and contribute to this wrapper project is to use the tools provided by GitHub:
You can also email me directly, I will answer any questions and requests.
The source code use the CamelCase naming style variant where :
No open issues yet, or sync has not completed.