vrshoot

diff libs/assimp/boost/scoped_ptr.hpp @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/boost/scoped_ptr.hpp	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,79 @@
     1.4 +
     1.5 +#ifndef __AI_BOOST_SCOPED_PTR_INCLUDED
     1.6 +#define __AI_BOOST_SCOPED_PTR_INCLUDED
     1.7 +
     1.8 +#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
     1.9 +
    1.10 +namespace boost {
    1.11 +
    1.12 +// small replacement for boost::scoped_ptr
    1.13 +template <class T>
    1.14 +class scoped_ptr
    1.15 +{
    1.16 +public:
    1.17 +
    1.18 +	// provide a default construtctor
    1.19 +	scoped_ptr()
    1.20 +		: ptr(0)
    1.21 +	{
    1.22 +	}
    1.23 +
    1.24 +	// construction from an existing heap object of type T
    1.25 +	scoped_ptr(T* _ptr)
    1.26 +		: ptr(_ptr)
    1.27 +	{
    1.28 +	}
    1.29 +
    1.30 +	// automatic destruction of the wrapped object at the
    1.31 +	// end of our lifetime
    1.32 +	~scoped_ptr()
    1.33 +	{
    1.34 +		delete ptr;
    1.35 +	}
    1.36 +
    1.37 +	inline T* get() const
    1.38 +	{
    1.39 +		return ptr;
    1.40 +	}
    1.41 +
    1.42 +	inline operator T*()
    1.43 +	{
    1.44 +		return ptr;
    1.45 +	}
    1.46 +
    1.47 +	inline T* operator-> ()
    1.48 +	{
    1.49 +		return ptr;
    1.50 +	}
    1.51 +
    1.52 +	inline void reset (T* t = 0)
    1.53 +	{
    1.54 +		delete ptr;
    1.55 +		ptr = t;
    1.56 +	}
    1.57 +
    1.58 +	void swap(scoped_ptr & b)
    1.59 +	{
    1.60 +		std::swap(ptr, b.ptr);
    1.61 +	}
    1.62 +
    1.63 +private:
    1.64 +
    1.65 +	// encapsulated object pointer
    1.66 +	T* ptr;
    1.67 +
    1.68 +};
    1.69 +
    1.70 +template<class T>
    1.71 +inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b)
    1.72 +{
    1.73 +	a.swap(b);
    1.74 +}
    1.75 +
    1.76 +} // end of namespace boost
    1.77 +
    1.78 +#else
    1.79 +#	error "scoped_ptr.h was already included"
    1.80 +#endif
    1.81 +#endif // __AI_BOOST_SCOPED_PTR_INCLUDED
    1.82 +