libstdc++
|
00001 // -*- C++ -*- 00002 00003 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 00004 // Free Software Foundation, Inc. 00005 // 00006 // This file is part of the GNU ISO C++ Library. This library is free 00007 // software; you can redistribute it and/or modify it under the terms 00008 // of the GNU General Public License as published by the Free Software 00009 // Foundation; either version 3, or (at your option) any later 00010 // version. 00011 00012 // This library is distributed in the hope that it will be useful, but 00013 // WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // 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 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 00027 00028 // Permission to use, copy, modify, sell, and distribute this software 00029 // is hereby granted without fee, provided that the above copyright 00030 // notice appears in all copies, and that both that copyright notice 00031 // and this permission notice appear in supporting documentation. None 00032 // of the above authors, nor IBM Haifa Research Laboratories, make any 00033 // representation about the suitability of this software for any 00034 // purpose. It is provided "as is" without express or implied 00035 // warranty. 00036 00037 /** 00038 * @file exception.hpp 00039 * Contains exception classes. 00040 */ 00041 00042 #ifndef PB_DS_EXCEPTION_HPP 00043 #define PB_DS_EXCEPTION_HPP 00044 00045 #include <bits/c++config.h> 00046 #include <stdexcept> 00047 #include <cstdlib> 00048 00049 namespace __gnu_pbds 00050 { 00051 // Base class for exceptions. 00052 struct container_error : public std::logic_error 00053 { 00054 container_error() 00055 : std::logic_error(__N("__gnu_pbds::container_error")) { } 00056 }; 00057 00058 // An entry cannot be inserted into a container object for logical 00059 // reasons (not, e.g., if memory is unabvailable, in which case 00060 // the allocator_type's exception will be thrown). 00061 struct insert_error : public container_error { }; 00062 00063 // A join cannot be performed logical reasons (i.e., the ranges of 00064 // the two container objects being joined overlaps. 00065 struct join_error : public container_error { }; 00066 00067 // A container cannot be resized. 00068 struct resize_error : public container_error { }; 00069 00070 #if __EXCEPTIONS 00071 inline void 00072 __throw_container_error(void) 00073 { throw container_error(); } 00074 00075 inline void 00076 __throw_insert_error(void) 00077 { throw insert_error(); } 00078 00079 inline void 00080 __throw_join_error(void) 00081 { throw join_error(); } 00082 00083 inline void 00084 __throw_resize_error(void) 00085 { throw resize_error(); } 00086 #else 00087 inline void 00088 __throw_container_error(void) 00089 { std::abort(); } 00090 00091 inline void 00092 __throw_insert_error(void) 00093 { std::abort(); } 00094 00095 inline void 00096 __throw_join_error(void) 00097 { std::abort(); } 00098 00099 inline void 00100 __throw_resize_error(void) 00101 { std::abort(); } 00102 #endif 00103 } // namespace __gnu_pbds 00104 00105 #endif