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(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT) 18 #include <cxxabi.h> 19 #endif 20 21 static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), ""); 22 23 24 namespace std // purposefully not using versioning namespace 25 { 26 27 logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) 28 { 29 } 30 31 logic_error::logic_error(const char* msg) : __imp_(msg) 32 { 33 } 34 35 logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) 36 { 37 } 38 39 logic_error& 40 logic_error::operator=(const logic_error& le) _NOEXCEPT 41 { 42 __imp_ = le.__imp_; 43 return *this; 44 } 45 46 #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) 47 48 logic_error::~logic_error() _NOEXCEPT 49 { 50 } 51 52 const char* 53 logic_error::what() const _NOEXCEPT 54 { 55 return __imp_.c_str(); 56 } 57 58 #endif 59 60 runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) 61 { 62 } 63 64 runtime_error::runtime_error(const char* msg) : __imp_(msg) 65 { 66 } 67 68 runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT 69 : __imp_(le.__imp_) 70 { 71 } 72 73 runtime_error& 74 runtime_error::operator=(const runtime_error& le) _NOEXCEPT 75 { 76 __imp_ = le.__imp_; 77 return *this; 78 } 79 80 #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) 81 82 runtime_error::~runtime_error() _NOEXCEPT 83 { 84 } 85 86 const char* 87 runtime_error::what() const _NOEXCEPT 88 { 89 return __imp_.c_str(); 90 } 91 92 domain_error::~domain_error() _NOEXCEPT {} 93 invalid_argument::~invalid_argument() _NOEXCEPT {} 94 length_error::~length_error() _NOEXCEPT {} 95 out_of_range::~out_of_range() _NOEXCEPT {} 96 97 range_error::~range_error() _NOEXCEPT {} 98 overflow_error::~overflow_error() _NOEXCEPT {} 99 underflow_error::~underflow_error() _NOEXCEPT {} 100 101 #endif 102 103 } // std 104