From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libcutl/cutl/shared-ptr/base.hxx | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 libcutl/cutl/shared-ptr/base.hxx (limited to 'libcutl/cutl/shared-ptr/base.hxx') diff --git a/libcutl/cutl/shared-ptr/base.hxx b/libcutl/cutl/shared-ptr/base.hxx new file mode 100644 index 0000000..f2bfecc --- /dev/null +++ b/libcutl/cutl/shared-ptr/base.hxx @@ -0,0 +1,92 @@ +// file : cutl/shared-ptr/base.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef CUTL_SHARED_PTR_BASE_HXX +#define CUTL_SHARED_PTR_BASE_HXX + +#include +#include // std::size_t + +#include + +#include + +namespace cutl +{ + struct LIBCUTL_EXPORT share + { + explicit + share (char id); + + bool + operator== (share) const; + + private: + char id_; + }; +} + +extern LIBCUTL_EXPORT cutl::share shared; +extern LIBCUTL_EXPORT cutl::share exclusive; + +LIBCUTL_EXPORT void* +operator new (std::size_t, cutl::share) throw (std::bad_alloc); + +LIBCUTL_EXPORT void +operator delete (void*, cutl::share) throw (); + +namespace cutl +{ + struct LIBCUTL_EXPORT not_shared: exception + { + virtual char const* + what () const throw (); + }; + + struct LIBCUTL_EXPORT shared_base + { + shared_base (); + shared_base (shared_base const&); + shared_base& + operator= (shared_base const&); + + void + _inc_ref (); + + bool + _dec_ref (); + + std::size_t + _ref_count () const; + + void* + operator new (std::size_t, share) throw (std::bad_alloc); + + void + operator delete (void*, share) throw (); + + void + operator delete (void*) throw (); + + protected: + std::size_t counter_; + }; + + template + inline X* + inc_ref (X*); + + template + inline void + dec_ref (X*); + + template + inline std::size_t + ref_count (X const*); +} + +#include +#include + +#endif // CUTL_SHARED_PTR_BASE_HXX -- cgit v1.2.3