]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - src/stdexcept.cpp
Vendor import of libc++ trunk r291012:
[FreeBSD/FreeBSD.git] / src / stdexcept.cpp
1 //===------------------------ stdexcept.cpp -------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "stdexcept"
11 #include "new"
12 #include "string"
13 #include "system_error"
14 #include "__refstring"
15
16 /* For _LIBCPPABI_VERSION */
17 #if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
18     (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT))
19 #include <cxxabi.h>
20 #endif
21
22 static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
23
24
25 namespace std  // purposefully not using versioning namespace
26 {
27
28 logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
29 {
30 }
31
32 logic_error::logic_error(const char* msg) : __imp_(msg)
33 {
34 }
35
36 logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
37 {
38 }
39
40 logic_error&
41 logic_error::operator=(const logic_error& le) _NOEXCEPT
42 {
43     __imp_ = le.__imp_;
44     return *this;
45 }
46
47 #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
48
49 logic_error::~logic_error() _NOEXCEPT
50 {
51 }
52
53 const char*
54 logic_error::what() const _NOEXCEPT
55 {
56     return __imp_.c_str();
57 }
58
59 #endif
60
61 runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
62 {
63 }
64
65 runtime_error::runtime_error(const char* msg) : __imp_(msg)
66 {
67 }
68
69 runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
70   : __imp_(le.__imp_)
71 {
72 }
73
74 runtime_error&
75 runtime_error::operator=(const runtime_error& le) _NOEXCEPT
76 {
77     __imp_ = le.__imp_;
78     return *this;
79 }
80
81 #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
82
83 runtime_error::~runtime_error() _NOEXCEPT
84 {
85 }
86
87 const char*
88 runtime_error::what() const _NOEXCEPT
89 {
90     return __imp_.c_str();
91 }
92
93 domain_error::~domain_error() _NOEXCEPT {}
94 invalid_argument::~invalid_argument() _NOEXCEPT {}
95 length_error::~length_error() _NOEXCEPT {}
96 out_of_range::~out_of_range() _NOEXCEPT {}
97
98 range_error::~range_error() _NOEXCEPT {}
99 overflow_error::~overflow_error() _NOEXCEPT {}
100 underflow_error::~underflow_error() _NOEXCEPT {}
101
102 #endif
103
104 }  // std