1 // 2 // Boost.Pointer Container 3 // 4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and 5 // distribution is subject to the Boost Software License, Version 6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // 9 // For more information, see http://www.boost.org/libs/ptr_container/ 10 // 11 12 #ifndef BOOST_PTR_CONTAINER_EXCEPTION_HPP 13 #define BOOST_PTR_CONTAINER_EXCEPTION_HPP 14 15 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 # pragma once 17 #endif 18 19 #include <exception> 20 21 namespace boost 22 { 23 class bad_ptr_container_operation : public std::exception 24 { 25 const char* what_; 26 public: bad_ptr_container_operation(const char * what)27 bad_ptr_container_operation( const char* what ) : what_( what ) 28 { } 29 what() const30 virtual const char* what() const throw() 31 { 32 return what_; 33 } 34 }; 35 36 37 38 class bad_index : public bad_ptr_container_operation 39 { 40 public: bad_index(const char * what)41 bad_index( const char* what ) : bad_ptr_container_operation( what ) 42 { } 43 }; 44 45 46 47 class bad_pointer : public bad_ptr_container_operation 48 { 49 public: bad_pointer()50 bad_pointer() : bad_ptr_container_operation( "Null pointer not allowed in a pointer container!" ) 51 { } 52 bad_pointer(const char * text)53 bad_pointer( const char* text ) : bad_ptr_container_operation( text ) 54 { } 55 }; 56 } 57 58 #endif 59