exception_ptr.h

Go to the documentation of this file.
00001 // Exception Handling support header (exception_ptr class) for -*- C++ -*-
00002 
00003 // Copyright (C) 2008, 2009 Free Software Foundation
00004 //
00005 // This file is part of GCC.
00006 //
00007 // GCC is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 3, or (at your option)
00010 // any later version.
00011 // 
00012 // GCC is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // 
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 /** @file exception_ptr.h
00027  *  This is an internal header file, included by other headers and the
00028  *  implementation. You should not attempt to use it directly.
00029  */
00030 
00031 #ifndef _EXCEPTION_PTR_H
00032 #define _EXCEPTION_PTR_H
00033 
00034 #pragma GCC visibility push(default)
00035 
00036 #include <bits/c++config.h>
00037 #include <exception_defines.h>
00038 
00039 #if !defined(_GLIBCXX_ATOMIC_BUILTINS_4)
00040 #  error This platform does not support exception propagation.
00041 #endif
00042 
00043 extern "C++" {
00044 
00045 namespace std 
00046 {
00047   /**
00048    * @addtogroup exceptions
00049    * @{
00050    */
00051 
00052   // Hide the free operators from other types
00053   namespace __exception_ptr
00054   {
00055     /**
00056      * @brief An opaque pointer to an arbitrary exception.
00057      */
00058     class exception_ptr;
00059   }
00060 
00061   using __exception_ptr::exception_ptr;
00062 
00063   /** Obtain an %exception_ptr to the currently handled exception. If there
00064    *  is none, or the currently handled exception is foreign, return the null
00065    *  value.
00066    */
00067   exception_ptr current_exception() throw();
00068 
00069   /// Throw the object pointed to by the %exception_ptr.
00070   void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__));
00071 
00072   /// Obtain an %exception_ptr pointing to a copy of the supplied object.
00073   template<typename _Ex>
00074     exception_ptr 
00075     copy_exception(_Ex __ex) throw();
00076 
00077   namespace __exception_ptr
00078   {
00079     bool 
00080     operator==(const exception_ptr&, const exception_ptr&) throw();
00081 
00082     bool 
00083     operator!=(const exception_ptr&, const exception_ptr&) throw();
00084 
00085     class exception_ptr
00086     {
00087       void* _M_exception_object;
00088 
00089       explicit exception_ptr(void* __e) throw();
00090 
00091       void _M_addref() throw();
00092       void _M_release() throw();
00093 
00094       void *_M_get() const throw();
00095 
00096       void _M_safe_bool_dummy();
00097 
00098       friend exception_ptr std::current_exception() throw();
00099       friend void std::rethrow_exception(exception_ptr);
00100 
00101     public:
00102       exception_ptr() throw();
00103 
00104       typedef void (exception_ptr::*__safe_bool)();
00105 
00106       // For construction from nullptr or 0.
00107       exception_ptr(__safe_bool) throw();
00108 
00109       exception_ptr(const exception_ptr&) throw();
00110 
00111 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00112       exception_ptr(exception_ptr&& __o) throw()
00113       : _M_exception_object(__o._M_exception_object)
00114       { __o._M_exception_object = 0; }
00115 #endif
00116 
00117       exception_ptr& 
00118       operator=(const exception_ptr&) throw();
00119 
00120 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00121       exception_ptr& 
00122       operator=(exception_ptr&& __o) throw()
00123       {
00124         exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
00125         return *this;
00126       }
00127 #endif
00128 
00129       ~exception_ptr() throw();
00130 
00131       void 
00132       swap(exception_ptr&) throw();
00133 
00134 #ifdef _GLIBCXX_EH_PTR_COMPAT
00135       // Retained for compatibility with CXXABI_1.3.
00136       bool operator!() const throw();
00137       operator __safe_bool() const throw();
00138 #endif
00139 
00140       friend bool 
00141       operator==(const exception_ptr&, const exception_ptr&) throw();
00142 
00143       const type_info*
00144       __cxa_exception_type() const throw();
00145     };
00146 
00147   } // namespace __exception_ptr
00148 
00149 
00150   template<typename _Ex>
00151     exception_ptr 
00152     copy_exception(_Ex __ex) throw()
00153     {
00154       __try
00155     {
00156       throw __ex;
00157     }
00158       __catch(...)
00159     {
00160       return current_exception ();
00161     }
00162     }
00163 
00164   // @} group exceptions
00165 } // namespace std
00166 
00167 } // extern "C++"
00168 
00169 #pragma GCC visibility pop
00170 
00171 #endif

Generated on Thu Jul 23 21:16:04 2009 for libstdc++ by  doxygen 1.5.8