BVB Source Codes

mars Show throw_exception.hpp Source code

Return Download mars: download throw_exception.hpp Source code - Download mars Source code - Type:.hpp
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10.  
  11. #ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP
  12. #define BOOST_CONTAINER_THROW_EXCEPTION_HPP
  13.  
  14. #ifndef BOOST_CONFIG_HPP
  15. #  include <boost/config.hpp>
  16. #endif
  17.  
  18. #if defined(BOOST_HAS_PRAGMA_ONCE)
  19. #  pragma once
  20. #endif
  21.  
  22. #include <boost/container/detail/config_begin.hpp>
  23. #include <boost/container/detail/workaround.hpp>
  24.  
  25. #ifndef BOOST_NO_EXCEPTIONS
  26.    #include <stdexcept> //for std exception types
  27.    #include <new>       //for std::bad_alloc
  28. #else
  29.    #include <boost/assert.hpp>
  30.    #include <cstdlib>   //for std::abort
  31. #endif
  32.  
  33. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  34. namespace container {
  35.  
  36. #if defined(BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS)
  37.    //The user must provide definitions for the following functions
  38.  
  39.    void throw_bad_alloc();
  40.  
  41.    void throw_out_of_range(const char* str);
  42.  
  43.    void throw_length_error(const char* str);
  44.  
  45.    void throw_logic_error(const char* str);
  46.  
  47.    void throw_runtime_error(const char* str);
  48.  
  49. #elif defined(BOOST_NO_EXCEPTIONS)
  50.  
  51.    inline void throw_bad_alloc()
  52.    {
  53.       BOOST_ASSERT(!"mars_boost::container bad_alloc thrown");
  54.       std::abort();
  55.    }
  56.  
  57.    inline void throw_out_of_range(const char* str)
  58.    {
  59.       BOOST_ASSERT_MSG(!"mars_boost::container out_of_range thrown", str);
  60.       std::abort();
  61.    }
  62.  
  63.    inline void throw_length_error(const char* str)
  64.    {
  65.       BOOST_ASSERT_MSG(!"mars_boost::container length_error thrown", str);
  66.       std::abort();
  67.    }
  68.  
  69.    inline void throw_logic_error(const char* str)
  70.    {
  71.       BOOST_ASSERT_MSG(!"mars_boost::container logic_error thrown", str);
  72.       std::abort();
  73.    }
  74.  
  75.    inline void throw_runtime_error(const char* str)
  76.    {
  77.       BOOST_ASSERT_MSG(!"mars_boost::container runtime_error thrown", str);
  78.       std::abort();
  79.    }
  80.  
  81. #else //defined(BOOST_NO_EXCEPTIONS)
  82.  
  83.    //! Exception callback called by Boost.Container when fails to allocate the requested storage space.
  84.    //! <ul>
  85.    //! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::bad_alloc()</code> is thrown.</li>
  86.    //!
  87.    //! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  88.    //!   is NOT defined <code>BOOST_ASSERT(!"mars_boost::container bad_alloc thrown")</code> is called
  89.    //!   and <code>std::abort()</code> if the former returns.</li>
  90.    //!
  91.    //! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  92.    //!   the user must provide an implementation and the function should not return.</li>
  93.    //! </ul>
  94.    inline void throw_bad_alloc()
  95.    {
  96.       throw std::bad_alloc();
  97.    }
  98.  
  99.    //! Exception callback called by Boost.Container to signal arguments out of range.
  100.    //! <ul>
  101.    //! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::out_of_range(str)</code> is thrown.</li>
  102.    //!
  103.    //! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  104.    //!   is NOT defined <code>BOOST_ASSERT_MSG(!"mars_boost::container out_of_range thrown", str)</code> is called
  105.    //!   and <code>std::abort()</code> if the former returns.</li>
  106.    //!
  107.    //! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  108.    //!   the user must provide an implementation and the function should not return.</li>
  109.    //! </ul>
  110.    inline void throw_out_of_range(const char* str)
  111.    {
  112.       throw std::out_of_range(str);
  113.    }
  114.  
  115.    //! Exception callback called by Boost.Container to signal errors resizing.
  116.    //! <ul>
  117.    //! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::length_error(str)</code> is thrown.</li>
  118.    //!
  119.    //! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  120.    //!   is NOT defined <code>BOOST_ASSERT_MSG(!"mars_boost::container length_error thrown", str)</code> is called
  121.    //!   and <code>std::abort()</code> if the former returns.</li>
  122.    //!
  123.    //! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  124.    //!   the user must provide an implementation and the function should not return.</li>
  125.    //! </ul>
  126.    inline void throw_length_error(const char* str)
  127.    {
  128.       throw std::length_error(str);
  129.    }
  130.  
  131.    //! Exception callback called by Boost.Container  to report errors in the internal logical
  132.    //! of the program, such as violation of logical preconditions or class invariants.
  133.    //! <ul>
  134.    //! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::logic_error(str)</code> is thrown.</li>
  135.    //!
  136.    //! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  137.    //!   is NOT defined <code>BOOST_ASSERT_MSG(!"mars_boost::container logic_error thrown", str)</code> is called
  138.    //!   and <code>std::abort()</code> if the former returns.</li>
  139.    //!
  140.    //! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  141.    //!   the user must provide an implementation and the function should not return.</li>
  142.    //! </ul>
  143.    inline void throw_logic_error(const char* str)
  144.    {
  145.       throw std::logic_error(str);
  146.    }
  147.  
  148.    //! Exception callback called by Boost.Container  to report errors that can only be detected during runtime.
  149.    //! <ul>
  150.    //! <li>If BOOST_NO_EXCEPTIONS is NOT defined <code>std::runtime_error(str)</code> is thrown.</li>
  151.    //!
  152.    //! <li>If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  153.    //!   is NOT defined <code>BOOST_ASSERT_MSG(!"mars_boost::container runtime_error thrown", str)</code> is called
  154.    //!   and <code>std::abort()</code> if the former returns.</li>
  155.    //!
  156.    //! <li>If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  157.    //!   the user must provide an implementation and the function should not return.</li>
  158.    //! </ul>
  159.    inline void throw_runtime_error(const char* str)
  160.    {
  161.       throw std::runtime_error(str);
  162.    }
  163.  
  164. #endif
  165.  
  166. }}  //namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace container {
  167.  
  168. #include <boost/container/detail/config_end.hpp>
  169.  
  170. #endif //#ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP
  171.  
downloadthrow_exception.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top