exception.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the terms
00007 // of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 2, or (at your option) any later
00009 // version.
00010 
00011 // This library is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this library; see the file COPYING.  If not, write to
00018 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00019 // MA 02111-1307, USA.
00020 
00021 // As a special exception, you may use this file as part of a free
00022 // software library without restriction.  Specifically, if other files
00023 // instantiate templates or use macros or inline functions from this
00024 // file, or you compile this file and link it with other files to
00025 // produce an executable, this file does not by itself cause the
00026 // resulting executable to be covered by the GNU General Public
00027 // License.  This exception does not however invalidate any other
00028 // reasons why the executable file might be covered by the GNU General
00029 // Public License.
00030 
00031 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00032 
00033 // Permission to use, copy, modify, sell, and distribute this software
00034 // is hereby granted without fee, provided that the above copyright
00035 // notice appears in all copies, and that both that copyright notice
00036 // and this permission notice appear in supporting documentation. None
00037 // of the above authors, nor IBM Haifa Research Laboratories, make any
00038 // representation about the suitability of this software for any
00039 // purpose. It is provided "as is" without express or implied
00040 // warranty.
00041 
00042 /**
00043  * @file exception.hpp
00044  * Contains exception classes.
00045  */
00046 
00047 #ifndef PB_DS_EXCEPTION_HPP
00048 #define PB_DS_EXCEPTION_HPP
00049 
00050 #include <stdexcept>
00051 #include <cstdlib>
00052 
00053 namespace __gnu_pbds
00054 {
00055   // Base class for exceptions.
00056   struct container_error : public std::logic_error
00057   {
00058     container_error() 
00059     : std::logic_error(__N("__gnu_pbds::container_error")) { }
00060   };
00061 
00062   // An entry cannot be inserted into a container object for logical
00063   // reasons (not, e.g., if memory is unabvailable, in which case
00064   // the allocator's exception will be thrown).
00065   struct insert_error : public container_error { };
00066 
00067   // A join cannot be performed logical reasons (i.e., the ranges of
00068   // the two container objects being joined overlaps.
00069   struct join_error : public container_error { };
00070 
00071   // A container cannot be resized.
00072   struct resize_error : public container_error { };
00073 
00074 #if __EXCEPTIONS
00075   void
00076   __throw_container_error(void)
00077   { throw container_error(); }
00078 
00079   void
00080   __throw_insert_error(void)
00081   { throw insert_error(); }
00082 
00083   void
00084   __throw_join_error(void)
00085   { throw join_error(); }
00086 
00087   void
00088   __throw_resize_error(void)
00089   { throw resize_error(); }
00090 #else
00091   void
00092   __throw_container_error(void)
00093   { std::abort(); }
00094 
00095   void
00096   __throw_insert_error(void)
00097   { std::abort(); }
00098 
00099   void
00100   __throw_join_error(void)
00101   { std::abort(); }
00102 
00103   void
00104   __throw_resize_error(void)
00105   { std::abort(); }
00106 #endif
00107 } // namespace __gnu_pbds
00108 
00109 #endif

Generated on Wed Mar 26 00:42:57 2008 for libstdc++ by  doxygen 1.5.1