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