IndexOutOfBoundsEvaluator.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-10
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <ls-std/core/evaluator/IndexOutOfBoundsEvaluator.hpp>
  11. #include <ls-std/core/exception/IndexOutOfBoundsException.hpp>
  12. using ls::standard::core::IndexOutOfBoundsEvaluator;
  13. using ls::standard::core::IndexOutOfBoundsException;
  14. using std::move;
  15. using std::string;
  16. IndexOutOfBoundsEvaluator::IndexOutOfBoundsEvaluator(const size_t _index, const size_t _size) : index(_index), size(_size)
  17. {}
  18. IndexOutOfBoundsEvaluator::IndexOutOfBoundsEvaluator(const size_t _index, const size_t _size, string _message) : index(_index), message(::move(_message)), size(_size)
  19. {}
  20. IndexOutOfBoundsEvaluator::~IndexOutOfBoundsEvaluator() noexcept = default;
  21. void IndexOutOfBoundsEvaluator::evaluate()
  22. {
  23. if (this->index >= this->size)
  24. {
  25. if (this->message.empty())
  26. {
  27. throw IndexOutOfBoundsException{};
  28. }
  29. throw IndexOutOfBoundsException{this->message};
  30. }
  31. }