1//===--------------------- stdexcept_default.ipp --------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "../../include/refstring.h"
10
11/* For _LIBCPPABI_VERSION */
12#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) &&                           \
13    (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) ||               \
14     defined(LIBCXXRT))
15#include <cxxabi.h>
16#endif
17
18static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), "");
19
20namespace std // purposefully not using versioning namespace
21{
22
23logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {}
24
25logic_error::logic_error(const char* msg) : __imp_(msg) {}
26
27logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) {}
28
29logic_error& logic_error::operator=(const logic_error& le) _NOEXCEPT {
30  __imp_ = le.__imp_;
31  return *this;
32}
33
34runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {}
35
36runtime_error::runtime_error(const char* msg) : __imp_(msg) {}
37
38runtime_error::runtime_error(const runtime_error& re) _NOEXCEPT
39    : __imp_(re.__imp_) {}
40
41runtime_error& runtime_error::operator=(const runtime_error& re) _NOEXCEPT {
42  __imp_ = re.__imp_;
43  return *this;
44}
45
46#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
47
48const char* logic_error::what() const _NOEXCEPT { return __imp_.c_str(); }
49
50const char* runtime_error::what() const _NOEXCEPT { return __imp_.c_str(); }
51
52logic_error::~logic_error() _NOEXCEPT {}
53domain_error::~domain_error() _NOEXCEPT {}
54invalid_argument::~invalid_argument() _NOEXCEPT {}
55length_error::~length_error() _NOEXCEPT {}
56out_of_range::~out_of_range() _NOEXCEPT {}
57
58runtime_error::~runtime_error() _NOEXCEPT {}
59range_error::~range_error() _NOEXCEPT {}
60overflow_error::~overflow_error() _NOEXCEPT {}
61underflow_error::~underflow_error() _NOEXCEPT {}
62
63#endif
64
65} // namespace std
66