File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/XS/libboost/mini.x/i/boost/container/throw_exception.hpp
Criterion Covered Total %
statement 0 4 0.0
branch 0 2 0.0
condition n/a
subroutine n/a
pod n/a
total 0 6 0.0


line stmt bran cond sub pod time code
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
16             #endif
17              
18             #if defined(BOOST_HAS_PRAGMA_ONCE)
19             # pragma once
20             #endif
21              
22             #include
23             #include
24              
25             #ifndef BOOST_NO_EXCEPTIONS
26             #include //for std exception types
27             #include //for implicit std::string conversion
28             #include //for std::bad_alloc
29             #else
30             #include
31             #include //for std::abort
32             #endif
33              
34             namespace boost {
35             namespace container {
36              
37             #if defined(BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS)
38             //The user must provide definitions for the following functions
39              
40             void throw_bad_alloc();
41              
42             void throw_out_of_range(const char* str);
43              
44             void throw_length_error(const char* str);
45              
46             void throw_logic_error(const char* str);
47              
48             void throw_runtime_error(const char* str);
49              
50             #elif defined(BOOST_NO_EXCEPTIONS)
51              
52             inline void throw_bad_alloc()
53             {
54             const char msg[] = "boost::container bad_alloc thrown";
55             (void)msg;
56             BOOST_ASSERT(!msg);
57             std::abort();
58             }
59              
60             inline void throw_out_of_range(const char* str)
61             {
62             const char msg[] = "boost::container out_of_range thrown";
63             (void)msg; (void)str;
64             BOOST_ASSERT_MSG(!msg, str);
65             std::abort();
66             }
67              
68             inline void throw_length_error(const char* str)
69             {
70             const char msg[] = "boost::container length_error thrown";
71             (void)msg; (void)str;
72             BOOST_ASSERT_MSG(!msg, str);
73             std::abort();
74             }
75              
76             inline void throw_logic_error(const char* str)
77             {
78             const char msg[] = "boost::container logic_error thrown";
79             (void)msg; (void)str;
80             BOOST_ASSERT_MSG(!msg, str);
81             std::abort();
82             }
83              
84             inline void throw_runtime_error(const char* str)
85             {
86             const char msg[] = "boost::container runtime_error thrown";
87             (void)msg; (void)str;
88             BOOST_ASSERT_MSG(!msg, str);
89             std::abort();
90             }
91              
92             #else //defined(BOOST_NO_EXCEPTIONS)
93              
94             //! Exception callback called by Boost.Container when fails to allocate the requested storage space.
95             //!
96             //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::bad_alloc() is thrown.
  • 97             //!
    98             //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  • 99             //! is NOT defined BOOST_ASSERT(!"boost::container bad_alloc thrown") is called
    100             //! and std::abort() if the former returns.
    101             //!
    102             //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  • 103             //! the user must provide an implementation and the function should not return.
    104             //!
    105 0           inline void throw_bad_alloc()
    106             {
    107 0           throw std::bad_alloc();
    108             }
    109              
    110             //! Exception callback called by Boost.Container to signal arguments out of range.
    111             //!
    112             //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::out_of_range(str) is thrown.
  • 113             //!
    114             //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  • 115             //! is NOT defined BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str) is called
    116             //! and std::abort() if the former returns.
    117             //!
    118             //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  • 119             //! the user must provide an implementation and the function should not return.
    120             //!
    121             inline void throw_out_of_range(const char* str)
    122             {
    123             throw std::out_of_range(str);
    124             }
    125              
    126             //! Exception callback called by Boost.Container to signal errors resizing.
    127             //!
    128             //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::length_error(str) is thrown.
  • 129             //!
    130             //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  • 131             //! is NOT defined BOOST_ASSERT_MSG(!"boost::container length_error thrown", str) is called
    132             //! and std::abort() if the former returns.
    133             //!
    134             //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  • 135             //! the user must provide an implementation and the function should not return.
    136             //!
    137 0           inline void throw_length_error(const char* str)
    138             {
    139 0 0         throw std::length_error(str);
    140             }
    141              
    142             //! Exception callback called by Boost.Container to report errors in the internal logical
    143             //! of the program, such as violation of logical preconditions or class invariants.
    144             //!
    145             //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::logic_error(str) is thrown.
  • 146             //!
    147             //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  • 148             //! is NOT defined BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str) is called
    149             //! and std::abort() if the former returns.
    150             //!
    151             //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  • 152             //! the user must provide an implementation and the function should not return.
    153             //!
    154             inline void throw_logic_error(const char* str)
    155             {
    156             throw std::logic_error(str);
    157             }
    158              
    159             //! Exception callback called by Boost.Container to report errors that can only be detected during runtime.
    160             //!
    161             //!
  • If BOOST_NO_EXCEPTIONS is NOT defined std::runtime_error(str) is thrown.
  • 162             //!
    163             //!
  • If BOOST_NO_EXCEPTIONS is defined and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
  • 164             //! is NOT defined BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str) is called
    165             //! and std::abort() if the former returns.
    166             //!
    167             //!
  • If BOOST_NO_EXCEPTIONS and BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS are defined
  • 168             //! the user must provide an implementation and the function should not return.
    169             //!
    170             inline void throw_runtime_error(const char* str)
    171             {
    172             throw std::runtime_error(str);
    173             }
    174              
    175             #endif
    176              
    177             }} //namespace boost { namespace container {
    178              
    179             #include
    180              
    181             #endif //#ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP