exception.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006 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 
00052 namespace pb_ds
00053 {
00054   // Base class for exceptions.
00055   struct container_error : public std::logic_error
00056   {
00057     container_error() 
00058     : std::logic_error(__N("pb_ds::container_error")) { }
00059   };
00060 
00061   // An entry cannot be inserted into a container object for logical
00062   // reasons (not, e.g., if memory is unabvailable, in which case
00063   // the allocator's exception will be thrown).
00064   struct insert_error : public container_error { };
00065 
00066   // A join cannot be performed logical reasons (i.e., the ranges of
00067   // the two container objects being joined overlaps.
00068   struct join_error : public container_error { };
00069 
00070   // A container cannot be resized.
00071   struct resize_error : public container_error { };
00072 
00073 #if __EXCEPTIONS
00074   void
00075   __throw_container_error(void)
00076   { throw container_error(); }
00077 
00078   void
00079   __throw_insert_error(void)
00080   { throw insert_error(); }
00081 
00082   void
00083   __throw_join_error(void)
00084   { throw join_error(); }
00085 
00086   void
00087   __throw_resize_error(void)
00088   { throw resize_error(); }
00089 #else
00090   void
00091   __throw_container_error(void)
00092   { std::abort(); }
00093 
00094   void
00095   __throw_insert_error(void)
00096   { std::abort(); }
00097 
00098   void
00099   __throw_join_error(void)
00100   { std::abort(); }
00101 
00102   void
00103   __throw_resize_error(void)
00104   { std::abort(); }
00105 #endif
00106 } // namespace pb_ds
00107 
00108 #endif

Generated on Thu Nov 1 13:11:29 2007 for libstdc++ by  doxygen 1.5.1