diff options
author | crupest <crupest@outlook.com> | 2019-03-21 22:44:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-21 22:44:31 +0800 |
commit | afdac77a66143375b5bebd4ff128b0fba87c5d21 (patch) | |
tree | 8c003a2d32e9411e55544114a3c2c14128909910 /src/ui/render/render_object.cpp | |
parent | b514247f79469c15959b00ca3276879033f932ff (diff) | |
download | cru-afdac77a66143375b5bebd4ff128b0fba87c5d21.tar.gz cru-afdac77a66143375b5bebd4ff128b0fba87c5d21.tar.bz2 cru-afdac77a66143375b5bebd4ff128b0fba87c5d21.zip |
Change all error handling.
Diffstat (limited to 'src/ui/render/render_object.cpp')
-rw-r--r-- | src/ui/render/render_object.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/ui/render/render_object.cpp b/src/ui/render/render_object.cpp index 0be44c1e..6380c2fe 100644 --- a/src/ui/render/render_object.cpp +++ b/src/ui/render/render_object.cpp @@ -4,15 +4,10 @@ namespace cru::ui::render { void RenderObject::AddChild(RenderObject* render_object, const int position) { - if (render_object->GetParent() != nullptr) - throw std::invalid_argument("Render object already has a parent."); - - if (position < 0) - throw std::invalid_argument("Position index is less than 0."); - - if (static_cast<std::vector<RenderObject*>::size_type>(position) > - children_.size()) - throw std::invalid_argument("Position index is out of bound."); + assert(render_object->GetParent() == + nullptr); // Render object already has a parent. + assert(position >= 0); // Position index is less than 0. + assert(position <= children_.size()); // Position index is out of bound. children_.insert(children_.cbegin() + position, render_object); render_object->SetParent(this); @@ -20,12 +15,8 @@ void RenderObject::AddChild(RenderObject* render_object, const int position) { } void RenderObject::RemoveChild(const int position) { - if (position < 0) - throw std::invalid_argument("Position index is less than 0."); - - if (static_cast<std::vector<RenderObject*>::size_type>(position) >= - children_.size()) - throw std::invalid_argument("Position index is out of bound."); + assert(position >= 0); // Position index is less than 0. + assert(position < children_.size()); // Position index is out of bound. const auto i = children_.cbegin() + position; const auto removed_child = *i; |