new

Go to the documentation of this file.
00001 // The -*- C++ -*- dynamic memory management header.
00002 
00003 // Copyright (C) 1994, 1996, 1997, 1998, 2000, 2001, 2002
00004 // Free Software Foundation
00005 
00006 // This file is part of GCC.
00007 //
00008 // GCC is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2, or (at your option)
00011 // any later version.
00012 // 
00013 // GCC is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 // 
00018 // You should have received a copy of the GNU General Public License
00019 // along with GCC; see the file COPYING.  If not, write to
00020 // the Free Software Foundation, 59 Temple Place - Suite 330,
00021 // Boston, MA 02111-1307, USA.
00022 
00023 // As a special exception, you may use this file as part of a free software
00024 // library without restriction.  Specifically, if other files instantiate
00025 // templates or use macros or inline functions from this file, or you compile
00026 // this file and link it with other files to produce an executable, this
00027 // file does not by itself cause the resulting executable to be covered by
00028 // the GNU General Public License.  This exception does not however
00029 // invalidate any other reasons why the executable file might be covered by
00030 // the GNU General Public License.
00031 
00038 #ifndef _NEW
00039 #define _NEW
00040 
00041 #include <cstddef>
00042 #include <exception>
00043 
00044 extern "C++" {
00045 
00046 namespace std 
00047 {
00053   class bad_alloc : public exception 
00054   {
00055   public:
00056     bad_alloc() throw() { }
00057     // This declaration is not useless:
00058     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
00059     virtual ~bad_alloc() throw();
00060   };
00061 
00062   struct nothrow_t { };
00063   extern const nothrow_t nothrow;
00066   typedef void (*new_handler)();
00068   new_handler set_new_handler(new_handler) throw();
00069 } // namespace std
00070 
00072 
00082 void* operator new(std::size_t) throw (std::bad_alloc);
00083 void* operator new[](std::size_t) throw (std::bad_alloc);
00084 void operator delete(void*) throw();
00085 void operator delete[](void*) throw();
00086 void* operator new(std::size_t, const std::nothrow_t&) throw();
00087 void* operator new[](std::size_t, const std::nothrow_t&) throw();
00088 void operator delete(void*, const std::nothrow_t&) throw();
00089 void operator delete[](void*, const std::nothrow_t&) throw();
00090 
00091 // Default placement versions of operator new.
00092 inline void* operator new(std::size_t, void* __p) throw() { return __p; }
00093 inline void* operator new[](std::size_t, void* __p) throw() { return __p; }
00094 
00095 // Default placement versions of operator delete.
00096 inline void  operator delete  (void*, void*) throw() { }
00097 inline void  operator delete[](void*, void*) throw() { }
00099 } // extern "C++"
00100 
00101 #endif

Generated on Tue Jan 30 17:31:52 2007 for GNU C++ STL by doxygen 1.3.6