stdexcept.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #include "__refstring"
  10. #include "stdexcept"
  11. #include "new"
  12. #include "string"
  13. #include "system_error"
  14. /* For _LIBCPPABI_VERSION */
  15. #if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)
  16. #include <cxxabi.h>
  17. #endif
  18. static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
  19. namespace std // purposefully not using versioning namespace
  20. {
  21. logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
  22. {
  23. }
  24. logic_error::logic_error(const char* msg) : __imp_(msg)
  25. {
  26. }
  27. logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
  28. {
  29. }
  30. logic_error&
  31. logic_error::operator=(const logic_error& le) _NOEXCEPT
  32. {
  33. __imp_ = le.__imp_;
  34. return *this;
  35. }
  36. #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
  37. logic_error::~logic_error() _NOEXCEPT
  38. {
  39. }
  40. const char*
  41. logic_error::what() const _NOEXCEPT
  42. {
  43. return __imp_.c_str();
  44. }
  45. #endif
  46. runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
  47. {
  48. }
  49. runtime_error::runtime_error(const char* msg) : __imp_(msg)
  50. {
  51. }
  52. runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
  53. : __imp_(le.__imp_)
  54. {
  55. }
  56. runtime_error&
  57. runtime_error::operator=(const runtime_error& le) _NOEXCEPT
  58. {
  59. __imp_ = le.__imp_;
  60. return *this;
  61. }
  62. #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
  63. runtime_error::~runtime_error() _NOEXCEPT
  64. {
  65. }
  66. const char*
  67. runtime_error::what() const _NOEXCEPT
  68. {
  69. return __imp_.c_str();
  70. }
  71. domain_error::~domain_error() _NOEXCEPT {}
  72. invalid_argument::~invalid_argument() _NOEXCEPT {}
  73. length_error::~length_error() _NOEXCEPT {}
  74. out_of_range::~out_of_range() _NOEXCEPT {}
  75. range_error::~range_error() _NOEXCEPT {}
  76. overflow_error::~overflow_error() _NOEXCEPT {}
  77. underflow_error::~underflow_error() _NOEXCEPT {}
  78. #endif
  79. } // std