| 1 | /*
|
|---|
| 2 | * Copyright (c) 2018 Jaroslav Jindrak
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | #ifndef LIBCPP_BITS_STDEXCEPT
|
|---|
| 30 | #define LIBCPP_BITS_STDEXCEPT
|
|---|
| 31 |
|
|---|
| 32 | #include <__bits/string/stringfwd.hpp>
|
|---|
| 33 | #include <__bits/trycatch.hpp>
|
|---|
| 34 | #include <exception>
|
|---|
| 35 | #include <iosfwd>
|
|---|
| 36 |
|
|---|
| 37 | namespace std
|
|---|
| 38 | {
|
|---|
| 39 | class logic_error: public exception
|
|---|
| 40 | {
|
|---|
| 41 | public:
|
|---|
| 42 | explicit logic_error(const string&);
|
|---|
| 43 | explicit logic_error(const char*);
|
|---|
| 44 | logic_error(const logic_error&) noexcept;
|
|---|
| 45 | logic_error& operator=(const logic_error&);
|
|---|
| 46 | ~logic_error() override;
|
|---|
| 47 |
|
|---|
| 48 | const char* what() const noexcept override;
|
|---|
| 49 |
|
|---|
| 50 | protected:
|
|---|
| 51 | char* what_;
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | class domain_error: public logic_error
|
|---|
| 55 | {
|
|---|
| 56 | public:
|
|---|
| 57 | explicit domain_error(const string&);
|
|---|
| 58 | explicit domain_error(const char*);
|
|---|
| 59 | domain_error(const domain_error&) noexcept;
|
|---|
| 60 | };
|
|---|
| 61 |
|
|---|
| 62 | class invalid_argument: public logic_error
|
|---|
| 63 | {
|
|---|
| 64 | public:
|
|---|
| 65 | explicit invalid_argument(const string&);
|
|---|
| 66 | explicit invalid_argument(const char*);
|
|---|
| 67 | invalid_argument(const invalid_argument&) noexcept;
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 | class length_error: public logic_error
|
|---|
| 71 | {
|
|---|
| 72 | public:
|
|---|
| 73 | explicit length_error(const string&);
|
|---|
| 74 | explicit length_error(const char*);
|
|---|
| 75 | length_error(const length_error&) noexcept;
|
|---|
| 76 | };
|
|---|
| 77 |
|
|---|
| 78 | class out_of_range: public logic_error
|
|---|
| 79 | {
|
|---|
| 80 | public:
|
|---|
| 81 | explicit out_of_range(const string&);
|
|---|
| 82 | explicit out_of_range(const char*);
|
|---|
| 83 | out_of_range(const out_of_range&) noexcept;
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | class runtime_error: public exception
|
|---|
| 87 | {
|
|---|
| 88 | public:
|
|---|
| 89 | explicit runtime_error(const string&);
|
|---|
| 90 | explicit runtime_error(const char*);
|
|---|
| 91 | runtime_error(const runtime_error&) noexcept;
|
|---|
| 92 | runtime_error& operator=(const runtime_error&);
|
|---|
| 93 | ~runtime_error() override;
|
|---|
| 94 |
|
|---|
| 95 | const char* what() const noexcept override;
|
|---|
| 96 |
|
|---|
| 97 | protected:
|
|---|
| 98 | char* what_;
|
|---|
| 99 | };
|
|---|
| 100 |
|
|---|
| 101 | class range_error: public runtime_error
|
|---|
| 102 | {
|
|---|
| 103 | public:
|
|---|
| 104 | explicit range_error(const string&);
|
|---|
| 105 | explicit range_error(const char*);
|
|---|
| 106 | range_error(const range_error&) noexcept;
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | class overflow_error: public runtime_error
|
|---|
| 110 | {
|
|---|
| 111 | public:
|
|---|
| 112 | explicit overflow_error(const string&);
|
|---|
| 113 | explicit overflow_error(const char*);
|
|---|
| 114 | overflow_error(const overflow_error&) noexcept;
|
|---|
| 115 | };
|
|---|
| 116 |
|
|---|
| 117 | class underflow_error: public runtime_error
|
|---|
| 118 | {
|
|---|
| 119 | public:
|
|---|
| 120 | explicit underflow_error(const string&);
|
|---|
| 121 | explicit underflow_error(const char*);
|
|---|
| 122 | underflow_error(const underflow_error&) noexcept;
|
|---|
| 123 | };
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | #endif
|
|---|