5#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_STDEXCEPT_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_STDEXCEPT_HPP_
16#include "arene/base/detail/raw_c_string.hpp"
35 arene::base::detail::character data_[storage_size]{};
44 explicit simple_string(arene::base::detail::raw_c_string
const str)
noexcept {
48 for (
std::size_t copied_count{}; copied_count + 1U < storage_size; ++copied_count) {
50 if (str[copied_count] ==
'\0') {
54 data_[copied_count] = str[copied_count];
85 return static_cast<arene::base::detail::raw_c_string
>(data_);
98 static constexpr arene::base::detail::raw_c_string default_exception_message{
"std::exception"};
105 exception() =
default;
108 exception(exception&&
move) =
default;
111 auto operator=(exception&&
move) -> exception& =
default;
114 exception(exception
const& copy) =
default;
117 auto operator=(exception
const& copy) -> exception& =
default;
119 virtual ~exception() =
default;
122 virtual auto what() const noexcept -> arene::base::detail::raw_c_string {
return default_exception_message; }
127class logic_error : exception {
131 static constexpr arene::base::detail::raw_c_string default_logic_error_message{
"std::logic_error"};
136 stdexcept_detail::simple_string message_{default_logic_error_message};
141 logic_error() =
default;
145 explicit logic_error(arene::base::detail::raw_c_string
const msg) noexcept
147 message_((msg !=
nullptr) ? msg : default_logic_error_message) {}
149 ~logic_error()
override =
default;
152 logic_error(logic_error&&
move) =
default;
155 logic_error(logic_error
const& copy) =
default;
158 auto operator=(logic_error&&
move) -> logic_error& =
default;
161 auto operator=(logic_error
const& copy) -> logic_error& =
default;
164 auto what() const noexcept -> arene::base::detail::raw_c_string
override {
return message_.c_str(); }
169class out_of_range : logic_error {
173 static constexpr arene::base::detail::raw_c_string default_out_of_range_message{
"std::out_of_range"};
181 out_of_range() noexcept
182 : out_of_range(default_out_of_range_message) {}
187 explicit out_of_range(arene::base::detail::raw_c_string
const msg) noexcept
188 : logic_error((msg !=
nullptr) ? msg : default_out_of_range_message) {}
190 ~out_of_range()
override =
default;
193 out_of_range(out_of_range&&
move) =
default;
196 out_of_range(out_of_range
const& copy) =
default;
199 auto operator=(out_of_range&&
move) -> out_of_range& =
default;
202 auto operator=(out_of_range
const& copy) -> out_of_range& =
default;
205 using logic_error::what;
211class runtime_error : exception {
215 static constexpr arene::base::detail::raw_c_string default_runtime_error_message{
"std::runtime_error"};
219 stdexcept_detail::simple_string message_{default_runtime_error_message};
224 runtime_error() =
default;
228 explicit runtime_error(arene::base::detail::raw_c_string
const msg) noexcept
230 message_((msg !=
nullptr) ? msg : default_runtime_error_message) {}
232 ~runtime_error()
override =
default;
235 runtime_error(runtime_error&&
move) =
default;
238 runtime_error(runtime_error
const& copy) =
default;
241 auto operator=(runtime_error&&
move) -> runtime_error& =
default;
244 auto operator=(runtime_error
const& copy) -> runtime_error& =
default;
247 auto what() const noexcept -> arene::base::detail::raw_c_string
override {
return message_.c_str(); }
simple_string(arene::base::detail::raw_c_string const str) noexcept
Construct a new simple string object.
Definition stdexcept.hpp:44
~simple_string() noexcept=default
dtor
auto c_str() const noexcept -> arene::base::detail::raw_c_string
Returns a pointer to the internal C-style string.
Definition stdexcept.hpp:84
Definition accumulate.hpp:36
Definition internal_disable_constexpr_in_cpp14.hpp:16
Definition stdexcept.hpp:21
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29