xref: /freebsd/contrib/llvm-project/libcxx/src/support/runtime/stdexcept_default.ipp (revision f7c32ed617858bcd22f8d1b03199099d50125721)
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(LIBCXXRT))
14#include <cxxabi.h>
15#endif
16
17static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), "");
18
19namespace std // purposefully not using versioning namespace
20{
21
22logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {}
23
24logic_error::logic_error(const char* msg) : __imp_(msg) {}
25
26logic_error::logic_error(const logic_error& le) noexcept : __imp_(le.__imp_) {}
27
28logic_error& logic_error::operator=(const logic_error& le) noexcept {
29  __imp_ = le.__imp_;
30  return *this;
31}
32
33runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {}
34
35runtime_error::runtime_error(const char* msg) : __imp_(msg) {}
36
37runtime_error::runtime_error(const runtime_error& re) noexcept
38    : __imp_(re.__imp_) {}
39
40runtime_error& runtime_error::operator=(const runtime_error& re) noexcept {
41  __imp_ = re.__imp_;
42  return *this;
43}
44
45#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
46
47const char* logic_error::what() const noexcept { return __imp_.c_str(); }
48
49const char* runtime_error::what() const noexcept { return __imp_.c_str(); }
50
51logic_error::~logic_error() noexcept {}
52domain_error::~domain_error() noexcept {}
53invalid_argument::~invalid_argument() noexcept {}
54length_error::~length_error() noexcept {}
55out_of_range::~out_of_range() noexcept {}
56
57runtime_error::~runtime_error() noexcept {}
58range_error::~range_error() noexcept {}
59overflow_error::~overflow_error() noexcept {}
60underflow_error::~underflow_error() noexcept {}
61
62#endif
63
64} // namespace std
65