1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

add SPROUT_ASSERT

This commit is contained in:
bolero-MURAKAMI 2013-03-18 19:12:21 +09:00
parent a5e14e71e1
commit 07f052fb6e
32 changed files with 386 additions and 284 deletions

View file

@ -1,12 +1,12 @@
#ifndef SPROUT_OPTIONAL_OPTIONAL_HPP
#define SPROUT_OPTIONAL_OPTIONAL_HPP
#include <stdexcept>
#include <sprout/config.hpp>
#include <sprout/utility/value_holder/value_holder.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/none.hpp>
#include <sprout/optional/nullopt.hpp>
#include <sprout/assert.hpp>
namespace sprout {
//
@ -120,13 +120,13 @@ namespace sprout {
return get();
}
SPROUT_CONSTEXPR reference_const_type get() const {
return is_initialized() ? val.get()
: (throw std::domain_error("optional: value not initialized"), val.get())
return SPROUT_ASSERT(is_initialized()) ? val.get()
: val.get()
;
}
reference_type get() {
return is_initialized() ? val.get()
: (throw std::domain_error("optional: value not initialized"), val.get())
return SPROUT_ASSERT(is_initialized()) ? val.get()
: val.get()
;
}
SPROUT_CONSTEXPR reference_const_type get_value_or(reference_const_type& v) const {
@ -141,23 +141,23 @@ namespace sprout {
}
SPROUT_CONSTEXPR pointer_const_type operator->() const {
return is_initialized() ? val.get_pointer()
: throw std::domain_error("optional: value not initialized")
return SPROUT_ASSERT(is_initialized()),
val.get_pointer()
;
}
pointer_type operator->() {
return is_initialized() ? val.get_pointer()
: throw std::domain_error("optional: value not initialized")
return SPROUT_ASSERT(is_initialized()),
val.get_pointer()
;
}
SPROUT_CONSTEXPR pointer_const_type get_pointer() const {
return is_initialized() ? val.get_pointer()
: throw std::domain_error("optional: value not initialized")
return SPROUT_ASSERT(is_initialized()),
val.get_pointer()
;
}
pointer_type get_pointer() {
return is_initialized() ? val.get_pointer()
: throw std::domain_error("optional: value not initialized")
return SPROUT_ASSERT(is_initialized()),
val.get_pointer()
;
}
SPROUT_CONSTEXPR pointer_const_type get_ptr() const {