Sha256: b14ea8bb5cbff27d812a9317207f060d12eae82b24c35055c82c67b71e6fce3c

Contents?: true

Size: 917 Bytes

Versions: 10

Compression:

Stored size: 917 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;

				if (!obj)
					this->reset();
				else if (!this->get())
					this->reset(new T(*obj));
				else
					*this->get() = *obj.get();

				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

10 entries across 10 versions & 1 rubygems

Version Path
xot-0.3 include/xot/pimpl.h
xot-0.2.1 include/xot/pimpl.h
xot-0.2 include/xot/pimpl.h
xot-0.1.42 include/xot/pimpl.h
xot-0.1.41 include/xot/pimpl.h
xot-0.1.40 include/xot/pimpl.h
xot-0.1.39 include/xot/pimpl.h
xot-0.1.38 include/xot/pimpl.h
xot-0.1.37 include/xot/pimpl.h
xot-0.1.36 include/xot/pimpl.h