Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/container for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP Chris@16: #define BOOST_CONTAINER_THROW_EXCEPTION_HPP Chris@16: Chris@101: #ifndef BOOST_CONFIG_HPP Chris@101: # include Chris@101: #endif Chris@101: Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@101: # pragma once Chris@101: #endif Chris@101: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifndef BOOST_NO_EXCEPTIONS Chris@16: #include //for std exception types Chris@16: #include //for std::bad_alloc Chris@16: #else Chris@16: #include Chris@16: #include //for std::abort Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: namespace container { Chris@16: Chris@16: #if defined(BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS) Chris@16: //The user must provide definitions for the following functions Chris@16: Chris@16: void throw_bad_alloc(); Chris@16: Chris@16: void throw_out_of_range(const char* str); Chris@16: Chris@16: void throw_length_error(const char* str); Chris@16: Chris@16: void throw_logic_error(const char* str); Chris@16: Chris@16: void throw_runtime_error(const char* str); Chris@16: Chris@16: #elif defined(BOOST_NO_EXCEPTIONS) Chris@16: Chris@16: inline void throw_bad_alloc() Chris@16: { Chris@16: BOOST_ASSERT(!"boost::container bad_alloc thrown"); Chris@16: std::abort(); Chris@16: } Chris@16: Chris@16: inline void throw_out_of_range(const char* str) Chris@16: { Chris@16: BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str); Chris@16: std::abort(); Chris@16: } Chris@16: Chris@16: inline void throw_length_error(const char* str) Chris@16: { Chris@16: BOOST_ASSERT_MSG(!"boost::container length_error thrown", str); Chris@16: std::abort(); Chris@16: } Chris@16: Chris@16: inline void throw_logic_error(const char* str) Chris@16: { Chris@16: BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str); Chris@16: std::abort(); Chris@16: } Chris@16: Chris@16: inline void throw_runtime_error(const char* str) Chris@16: { Chris@16: BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str); Chris@16: std::abort(); Chris@16: } Chris@16: Chris@16: #else //defined(BOOST_NO_EXCEPTIONS) Chris@16: Chris@101: //! Exception callback called by Boost.Container when fails to allocate the requested storage space. Chris@101: //!
    Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::bad_alloc() is thrown.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS Chris@101: //! is NOT defined BOOST_ASSERT(!"boost::container bad_alloc thrown") is called Chris@101: //! and std::abort() if the former returns.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined Chris@101: //! the user must provide an implementation and the function should not return.
  • Chris@101: //!
Chris@16: inline void throw_bad_alloc() Chris@16: { Chris@16: throw std::bad_alloc(); Chris@16: } Chris@16: Chris@101: //! Exception callback called by Boost.Container to signal arguments out of range. Chris@101: //!
    Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::out_of_range(str) is thrown.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS Chris@101: //! is NOT defined BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str) is called Chris@101: //! and std::abort() if the former returns.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined Chris@101: //! the user must provide an implementation and the function should not return.
  • Chris@101: //!
Chris@16: inline void throw_out_of_range(const char* str) Chris@16: { Chris@16: throw std::out_of_range(str); Chris@16: } Chris@16: Chris@101: //! Exception callback called by Boost.Container to signal errors resizing. Chris@101: //!
    Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::length_error(str) is thrown.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS Chris@101: //! is NOT defined BOOST_ASSERT_MSG(!"boost::container length_error thrown", str) is called Chris@101: //! and std::abort() if the former returns.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined Chris@101: //! the user must provide an implementation and the function should not return.
  • Chris@101: //!
Chris@16: inline void throw_length_error(const char* str) Chris@16: { Chris@16: throw std::length_error(str); Chris@16: } Chris@16: Chris@101: //! Exception callback called by Boost.Container to report errors in the internal logical Chris@101: //! of the program, such as violation of logical preconditions or class invariants. Chris@101: //!
    Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::logic_error(str) is thrown.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS Chris@101: //! is NOT defined BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str) is called Chris@101: //! and std::abort() if the former returns.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined Chris@101: //! the user must provide an implementation and the function should not return.
  • Chris@101: //!
Chris@16: inline void throw_logic_error(const char* str) Chris@16: { Chris@16: throw std::logic_error(str); Chris@16: } Chris@16: Chris@101: //! Exception callback called by Boost.Container to report errors that can only be detected during runtime. Chris@101: //!
    Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::runtime_error(str) is thrown.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS Chris@101: //! is NOT defined BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str) is called Chris@101: //! and std::abort() if the former returns.
  • Chris@101: //! Chris@101: //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined Chris@101: //! the user must provide an implementation and the function should not return.
  • Chris@101: //!
Chris@16: inline void throw_runtime_error(const char* str) Chris@16: { Chris@16: throw std::runtime_error(str); Chris@16: } Chris@16: Chris@16: #endif Chris@16: Chris@16: }} //namespace boost { namespace container { Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //#ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP