1*e4b17023SJohn Marino // -*- C++ -*- 2*e4b17023SJohn Marino 3*e4b17023SJohn Marino // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 4*e4b17023SJohn Marino // Free Software Foundation, Inc. 5*e4b17023SJohn Marino // 6*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library. This library is free 7*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the terms 8*e4b17023SJohn Marino // of the GNU General Public License as published by the Free Software 9*e4b17023SJohn Marino // Foundation; either version 3, or (at your option) any later 10*e4b17023SJohn Marino // version. 11*e4b17023SJohn Marino 12*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful, but 13*e4b17023SJohn Marino // WITHOUT ANY WARRANTY; without even the implied warranty of 14*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15*e4b17023SJohn Marino // General Public License for more details. 16*e4b17023SJohn Marino 17*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional 18*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version 19*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation. 20*e4b17023SJohn Marino 21*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and 22*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program; 23*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>. 25*e4b17023SJohn Marino 26*e4b17023SJohn Marino // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 27*e4b17023SJohn Marino 28*e4b17023SJohn Marino // Permission to use, copy, modify, sell, and distribute this software 29*e4b17023SJohn Marino // is hereby granted without fee, provided that the above copyright 30*e4b17023SJohn Marino // notice appears in all copies, and that both that copyright notice 31*e4b17023SJohn Marino // and this permission notice appear in supporting documentation. None 32*e4b17023SJohn Marino // of the above authors, nor IBM Haifa Research Laboratories, make any 33*e4b17023SJohn Marino // representation about the suitability of this software for any 34*e4b17023SJohn Marino // purpose. It is provided "as is" without express or implied 35*e4b17023SJohn Marino // warranty. 36*e4b17023SJohn Marino 37*e4b17023SJohn Marino /** 38*e4b17023SJohn Marino * @file exception.hpp 39*e4b17023SJohn Marino * Contains exception classes. 40*e4b17023SJohn Marino */ 41*e4b17023SJohn Marino 42*e4b17023SJohn Marino #ifndef PB_DS_EXCEPTION_HPP 43*e4b17023SJohn Marino #define PB_DS_EXCEPTION_HPP 44*e4b17023SJohn Marino 45*e4b17023SJohn Marino #include <bits/c++config.h> 46*e4b17023SJohn Marino #include <stdexcept> 47*e4b17023SJohn Marino #include <cstdlib> 48*e4b17023SJohn Marino 49*e4b17023SJohn Marino namespace __gnu_pbds 50*e4b17023SJohn Marino { 51*e4b17023SJohn Marino /** 52*e4b17023SJohn Marino * @defgroup exceptions-pbds Exceptions 53*e4b17023SJohn Marino * @ingroup pbds 54*e4b17023SJohn Marino * @{ 55*e4b17023SJohn Marino */ 56*e4b17023SJohn Marino 57*e4b17023SJohn Marino /// Base class for exceptions. 58*e4b17023SJohn Marino struct container_error : public std::logic_error 59*e4b17023SJohn Marino { container_error__gnu_pbds::container_error60*e4b17023SJohn Marino container_error() 61*e4b17023SJohn Marino : std::logic_error(__N("__gnu_pbds::container_error")) { } 62*e4b17023SJohn Marino }; 63*e4b17023SJohn Marino 64*e4b17023SJohn Marino /// An entry cannot be inserted into a container object for logical 65*e4b17023SJohn Marino /// reasons (not, e.g., if memory is unabvailable, in which case 66*e4b17023SJohn Marino /// the allocator_type's exception will be thrown). 67*e4b17023SJohn Marino struct insert_error : public container_error { }; 68*e4b17023SJohn Marino 69*e4b17023SJohn Marino /// A join cannot be performed logical reasons (i.e., the ranges of 70*e4b17023SJohn Marino /// the two container objects being joined overlaps. 71*e4b17023SJohn Marino struct join_error : public container_error { }; 72*e4b17023SJohn Marino 73*e4b17023SJohn Marino /// A container cannot be resized. 74*e4b17023SJohn Marino struct resize_error : public container_error { }; 75*e4b17023SJohn Marino 76*e4b17023SJohn Marino #if __EXCEPTIONS 77*e4b17023SJohn Marino inline void __throw_container_error(void)78*e4b17023SJohn Marino __throw_container_error(void) 79*e4b17023SJohn Marino { throw container_error(); } 80*e4b17023SJohn Marino 81*e4b17023SJohn Marino inline void __throw_insert_error(void)82*e4b17023SJohn Marino __throw_insert_error(void) 83*e4b17023SJohn Marino { throw insert_error(); } 84*e4b17023SJohn Marino 85*e4b17023SJohn Marino inline void __throw_join_error(void)86*e4b17023SJohn Marino __throw_join_error(void) 87*e4b17023SJohn Marino { throw join_error(); } 88*e4b17023SJohn Marino 89*e4b17023SJohn Marino inline void __throw_resize_error(void)90*e4b17023SJohn Marino __throw_resize_error(void) 91*e4b17023SJohn Marino { throw resize_error(); } 92*e4b17023SJohn Marino #else 93*e4b17023SJohn Marino inline void __throw_container_error(void)94*e4b17023SJohn Marino __throw_container_error(void) 95*e4b17023SJohn Marino { std::abort(); } 96*e4b17023SJohn Marino 97*e4b17023SJohn Marino inline void __throw_insert_error(void)98*e4b17023SJohn Marino __throw_insert_error(void) 99*e4b17023SJohn Marino { std::abort(); } 100*e4b17023SJohn Marino 101*e4b17023SJohn Marino inline void __throw_join_error(void)102*e4b17023SJohn Marino __throw_join_error(void) 103*e4b17023SJohn Marino { std::abort(); } 104*e4b17023SJohn Marino 105*e4b17023SJohn Marino inline void __throw_resize_error(void)106*e4b17023SJohn Marino __throw_resize_error(void) 107*e4b17023SJohn Marino { std::abort(); } 108*e4b17023SJohn Marino #endif 109*e4b17023SJohn Marino //@} 110*e4b17023SJohn Marino } // namespace __gnu_pbds 111*e4b17023SJohn Marino 112*e4b17023SJohn Marino #endif 113