xref: /minix3/external/bsd/libc++/dist/libcxx/src/stdexcept.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
14684ddb6SLionel Sambuc //===------------------------ stdexcept.cpp -------------------------------===//
24684ddb6SLionel Sambuc //
34684ddb6SLionel Sambuc //                     The LLVM Compiler Infrastructure
44684ddb6SLionel Sambuc //
54684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
64684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
74684ddb6SLionel Sambuc //
84684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
94684ddb6SLionel Sambuc 
10*0a6a1f1dSLionel Sambuc #include "__refstring"
114684ddb6SLionel Sambuc #include "stdexcept"
124684ddb6SLionel Sambuc #include "new"
134684ddb6SLionel Sambuc #include "string"
144684ddb6SLionel Sambuc #include "system_error"
154684ddb6SLionel Sambuc 
164684ddb6SLionel Sambuc #ifndef __has_include
174684ddb6SLionel Sambuc #define __has_include(inc) 0
184684ddb6SLionel Sambuc #endif
194684ddb6SLionel Sambuc 
20*0a6a1f1dSLionel Sambuc /* For _LIBCPPABI_VERSION */
21*0a6a1f1dSLionel Sambuc #if __has_include(<cxxabi.h>) || defined(__APPLE_) || defined(LIBCXXRT)
224684ddb6SLionel Sambuc #include <cxxabi.h>
234684ddb6SLionel Sambuc #endif
244684ddb6SLionel Sambuc 
25*0a6a1f1dSLionel Sambuc static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
264684ddb6SLionel Sambuc 
274684ddb6SLionel Sambuc namespace std  // purposefully not using versioning namespace
284684ddb6SLionel Sambuc {
294684ddb6SLionel Sambuc 
logic_error(const string & msg)30*0a6a1f1dSLionel Sambuc logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
314684ddb6SLionel Sambuc {
324684ddb6SLionel Sambuc }
334684ddb6SLionel Sambuc 
logic_error(const char * msg)34*0a6a1f1dSLionel Sambuc logic_error::logic_error(const char* msg) : __imp_(msg)
354684ddb6SLionel Sambuc {
364684ddb6SLionel Sambuc }
374684ddb6SLionel Sambuc 
logic_error(const logic_error & le)38*0a6a1f1dSLionel Sambuc logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
394684ddb6SLionel Sambuc {
404684ddb6SLionel Sambuc }
414684ddb6SLionel Sambuc 
424684ddb6SLionel Sambuc logic_error&
operator =(const logic_error & le)434684ddb6SLionel Sambuc logic_error::operator=(const logic_error& le) _NOEXCEPT
444684ddb6SLionel Sambuc {
45*0a6a1f1dSLionel Sambuc     __imp_ = le.__imp_;
464684ddb6SLionel Sambuc     return *this;
474684ddb6SLionel Sambuc }
484684ddb6SLionel Sambuc 
494684ddb6SLionel Sambuc #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
504684ddb6SLionel Sambuc 
~logic_error()514684ddb6SLionel Sambuc logic_error::~logic_error() _NOEXCEPT
524684ddb6SLionel Sambuc {
534684ddb6SLionel Sambuc }
544684ddb6SLionel Sambuc 
554684ddb6SLionel Sambuc const char*
what() const564684ddb6SLionel Sambuc logic_error::what() const _NOEXCEPT
574684ddb6SLionel Sambuc {
58*0a6a1f1dSLionel Sambuc     return __imp_.c_str();
594684ddb6SLionel Sambuc }
604684ddb6SLionel Sambuc 
614684ddb6SLionel Sambuc #endif
624684ddb6SLionel Sambuc 
runtime_error(const string & msg)63*0a6a1f1dSLionel Sambuc runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
644684ddb6SLionel Sambuc {
654684ddb6SLionel Sambuc }
664684ddb6SLionel Sambuc 
runtime_error(const char * msg)67*0a6a1f1dSLionel Sambuc runtime_error::runtime_error(const char* msg) : __imp_(msg)
684684ddb6SLionel Sambuc {
694684ddb6SLionel Sambuc }
704684ddb6SLionel Sambuc 
runtime_error(const runtime_error & le)714684ddb6SLionel Sambuc runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
72*0a6a1f1dSLionel Sambuc   : __imp_(le.__imp_)
734684ddb6SLionel Sambuc {
744684ddb6SLionel Sambuc }
754684ddb6SLionel Sambuc 
764684ddb6SLionel Sambuc runtime_error&
operator =(const runtime_error & le)774684ddb6SLionel Sambuc runtime_error::operator=(const runtime_error& le) _NOEXCEPT
784684ddb6SLionel Sambuc {
79*0a6a1f1dSLionel Sambuc     __imp_ = le.__imp_;
804684ddb6SLionel Sambuc     return *this;
814684ddb6SLionel Sambuc }
824684ddb6SLionel Sambuc 
834684ddb6SLionel Sambuc #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
844684ddb6SLionel Sambuc 
~runtime_error()854684ddb6SLionel Sambuc runtime_error::~runtime_error() _NOEXCEPT
864684ddb6SLionel Sambuc {
874684ddb6SLionel Sambuc }
884684ddb6SLionel Sambuc 
894684ddb6SLionel Sambuc const char*
what() const904684ddb6SLionel Sambuc runtime_error::what() const _NOEXCEPT
914684ddb6SLionel Sambuc {
92*0a6a1f1dSLionel Sambuc     return __imp_.c_str();
934684ddb6SLionel Sambuc }
944684ddb6SLionel Sambuc 
~domain_error()954684ddb6SLionel Sambuc domain_error::~domain_error() _NOEXCEPT {}
~invalid_argument()964684ddb6SLionel Sambuc invalid_argument::~invalid_argument() _NOEXCEPT {}
~length_error()974684ddb6SLionel Sambuc length_error::~length_error() _NOEXCEPT {}
~out_of_range()984684ddb6SLionel Sambuc out_of_range::~out_of_range() _NOEXCEPT {}
994684ddb6SLionel Sambuc 
~range_error()1004684ddb6SLionel Sambuc range_error::~range_error() _NOEXCEPT {}
~overflow_error()1014684ddb6SLionel Sambuc overflow_error::~overflow_error() _NOEXCEPT {}
~underflow_error()1024684ddb6SLionel Sambuc underflow_error::~underflow_error() _NOEXCEPT {}
1034684ddb6SLionel Sambuc 
1044684ddb6SLionel Sambuc #endif
1054684ddb6SLionel Sambuc 
1064684ddb6SLionel Sambuc }  // std
107