stdexcept.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright 2010-2011 PathScale, Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * 1. Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. *
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
  15. * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  24. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. /**
  27. * stdexcept.h - provides a stub version of <stdexcept>, which defines enough
  28. * of the exceptions for the runtime to use.
  29. */
  30. namespace std
  31. {
  32. class exception
  33. {
  34. public:
  35. exception() noexcept;
  36. exception(const exception&) noexcept;
  37. exception& operator=(const exception&) noexcept;
  38. virtual ~exception();
  39. virtual const char* what() const noexcept;
  40. };
  41. /**
  42. * Bad allocation exception. Thrown by ::operator new() if it fails.
  43. */
  44. class bad_alloc: public exception
  45. {
  46. public:
  47. bad_alloc() noexcept;
  48. bad_alloc(const bad_alloc&) noexcept;
  49. bad_alloc& operator=(const bad_alloc&) noexcept;
  50. ~bad_alloc();
  51. virtual const char* what() const noexcept;
  52. };
  53. /**
  54. * Bad cast exception. Thrown by the __cxa_bad_cast() helper function.
  55. */
  56. class bad_cast: public exception {
  57. public:
  58. bad_cast() noexcept;
  59. bad_cast(const bad_cast&) noexcept;
  60. bad_cast& operator=(const bad_cast&) noexcept;
  61. virtual ~bad_cast();
  62. virtual const char* what() const noexcept;
  63. };
  64. /**
  65. * Bad typeidexception. Thrown by the __cxa_bad_typeid() helper function.
  66. */
  67. class bad_typeid: public exception
  68. {
  69. public:
  70. bad_typeid() noexcept;
  71. bad_typeid(const bad_typeid &__rhs) noexcept;
  72. virtual ~bad_typeid();
  73. bad_typeid& operator=(const bad_typeid &__rhs) noexcept;
  74. virtual const char* what() const noexcept;
  75. };
  76. class bad_array_new_length: public bad_alloc
  77. {
  78. public:
  79. bad_array_new_length() noexcept;
  80. bad_array_new_length(const bad_array_new_length&) noexcept;
  81. bad_array_new_length& operator=(const bad_array_new_length&) noexcept;
  82. virtual ~bad_array_new_length();
  83. virtual const char *what() const noexcept;
  84. };
  85. } // namespace std