⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strictptr.hpp

📁 ACE编程的一本经典BIBLE的源代码,喜欢网络编程的别错过
💻 HPP
字号:
// file      : Utility/ReferenceCounting/StrictPtr.hpp
// author    : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2002-2003 Boris Kolpackov
// license   : http://kolpackov.net/license.html

#ifndef UTILITY_REFERENCE_COUNTING_STRICT_PTR_HPP
#define UTILITY_REFERENCE_COUNTING_STRICT_PTR_HPP

#include "Utility/ExH/Compound.hpp"
#include "Utility/ExH/Logic/DescriptiveException.hpp"

#include "Utility/ReferenceCounting/Interface.hpp"

namespace Utility
{
  namespace ReferenceCounting
  {
    template <typename T>
    class StrictPtr
    {
    public:
      typedef
      T
      Type;

      class NotInitialized_ {};
      typedef
      ExH::Compound<NotInitialized_, ExH::Logic::DescriptiveException>
      NotInitialized;

    public:
      // c-tor's

      StrictPtr () throw ();

      explicit
      StrictPtr (Type* ptr) throw ();

      StrictPtr (StrictPtr<Type> const& s_ptr)
        throw (Interface::Exception, Interface::SystemException);

      template <typename Other>
      StrictPtr (StrictPtr<Other> const& s_ptr)
        throw (Interface::Exception, Interface::SystemException);
      // d-tor

      ~StrictPtr () throw ();

      // assignment & copy-assignment operators

      StrictPtr<Type>&
      operator= (Type* ptr) throw ();

      StrictPtr<Type>&
      operator= (StrictPtr<Type> const& s_ptr)
        throw (Interface::Exception, Interface::SystemException);

      template <typename Other>
      StrictPtr<Type>&
      operator= (StrictPtr<Other> const& s_ptr)
        throw (Interface::Exception, Interface::SystemException);

      // conversions

      // Note: implicit conversion (operator Type* ()) is not supported.

      // comparison

      bool
      operator== (Type* other) const throw ();

      bool
      operator!= (Type* other) const throw ();

      // accessors

      Type*
      operator-> () const throw (NotInitialized);

      Type*
      in () const throw ();

      Type*
      retn() throw ();

    private:
      Type* ptr_;
    };

    // Specialization of add_ref function for StrictPtr<T>
    template <typename T>
    T*
    add_ref (StrictPtr<T> const& ptr)
      throw (Interface::Exception, Interface::SystemException);

    // Dynamic type conversion function for StrictPtr's
    template <typename D, typename S>
    StrictPtr<D>
    strict_cast (StrictPtr<S> const& s)
      throw (Interface::Exception, Interface::SystemException);
  }
}

#include "Utility/ReferenceCounting/StrictPtr.tpp"

#endif  // UTILITY_REFERENCE_COUNTING_STRICT_PTR_HPP

//StrictPtr.hpp,v 1.1 2005/05/24 04:33:13 turkaye Exp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -