Sha256: ea21b0e75f289fd0ca4e8a0a540abf994e5e7f443a9e7454a406b7a672a7622f

Contents?: true

Size: 826 Bytes

Versions: 13

Compression:

Stored size: 826 Bytes

Contents

// -*- c++ -*-
#pragma once
#ifndef __XOT_PIMPL_H__
#define __XOT_PIMPL_H__


#include <memory>


namespace Xot
{


	template <typename T>
	class PImpl : public std::unique_ptr<T>
	{

		typedef std::unique_ptr<T> Super;

		typedef PImpl<T> This;

		public:

			PImpl () : Super(new T) {}

			PImpl (T* p) : Super(p) {}

			PImpl (const This& obj)
			:	Super(obj ? new T(*obj) : NULL)
			{
			}

			This& operator = (const This& obj)
			{
				if (&obj == this) return *this;

				this->reset(obj ? new T(*obj) : NULL);
				return *this;
			}

	};// PImpl


	template <typename T>
	class PSharedImpl : public std::shared_ptr<T>
	{

		typedef std::shared_ptr<T> Super;

		typedef PSharedImpl<T> This;

		public:

			PSharedImpl () : Super(new T) {}

			PSharedImpl (T* p) : Super(p) {}

	};// PSharedImpl


}// Xot


#endif//EOH

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
xot-0.1.35 include/xot/pimpl.h
xot-0.1.34 include/xot/pimpl.h
xot-0.1.33 include/xot/pimpl.h
xot-0.1.32 include/xot/pimpl.h
xot-0.1.31 include/xot/pimpl.h
xot-0.1.30 include/xot/pimpl.h
xot-0.1.29 include/xot/pimpl.h
xot-0.1.28 include/xot/pimpl.h
xot-0.1.27 include/xot/pimpl.h
xot-0.1.26 include/xot/pimpl.h
xot-0.1.25 include/xot/pimpl.h
xot-0.1.24 include/xot/pimpl.h
xot-0.1.23 include/xot/pimpl.h