diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-21 11:11:23 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-21 11:11:23 +0100 |
| commit | 185335e8efcac46e96e25e5a50e0d4b93152f983 (patch) | |
| tree | 8b5f824d4913aa7a3d3e70df0aaa6c0980b81122 /include/ocl/option.hpp | |
| parent | 646d97f28c2891d634e3066535524fa28e297045 (diff) | |
feat: New release of `OCL.Core`, standalone module.v3.0
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/ocl/option.hpp')
| -rw-r--r-- | include/ocl/option.hpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/include/ocl/option.hpp b/include/ocl/option.hpp index 07cf194..93e01c7 100644 --- a/include/ocl/option.hpp +++ b/include/ocl/option.hpp @@ -8,7 +8,7 @@ #define __OCL_CORE_OPTION #include <ocl/detail/config.hpp> -#include <utility> +#include <ocl/print.hpp> namespace ocl { @@ -24,9 +24,9 @@ namespace ocl { using option_error = std::runtime_error; - void throw_option_invalid_type_error() + inline void throw_option_invalid_type_error(const boost::string_view& loc = BOOST_CURRENT_LOCATION.to_string()) { - throw option_error("option has invalid type."); + throw option_error(loc.to_string()); } } // namespace detail @@ -52,21 +52,22 @@ namespace ocl if (ret_ == return_type::err) { - throw detail::option_error(input ? input : "option::error"); + io::println(input ? input : "option::error"); + detail::throw_option_invalid_type_error(); } return *this; } template <typename Handleable> - option& expect_or_handle(const char* input) + option& expect(const char* input) { assert(ret_ != return_type::invalid); if (ret_ == return_type::err) { // AMLALE: Shall it be a functor or container here? - Handleable(input ? input : "option::error"); + Handleable{}(input ? input : "option::error"); } return *this; @@ -81,19 +82,7 @@ namespace ocl // AMLALE: The operator() are marked as `noexcept` as failing conditions within an evaluation (say a overloads operator==) proves that the // predictate is wrong. Thus program state is undefined. - struct teller - { - teller() = default; - virtual ~teller() = default; - - template <class ObjFirst, class ObjLast> - bool operator()(ObjFirst a, ObjLast b) noexcept - { - return false; - } - }; - - struct eq_teller final : teller + struct eq_teller final { template <class ObjFirst, class ObjLast> bool operator()(ObjFirst a, ObjLast b) noexcept @@ -102,7 +91,7 @@ namespace ocl } }; - struct greater_than_teller final : teller + struct greater_than_teller final { template <class ObjFirst, class ObjLast> bool operator()(ObjFirst a, ObjLast b) noexcept @@ -111,7 +100,7 @@ namespace ocl } }; - struct less_than_teller final : teller + struct less_than_teller final { template <class ObjFirst, class ObjLast> bool operator()(ObjFirst a, ObjLast b) noexcept @@ -124,7 +113,6 @@ namespace ocl template <typename Teller, typename... Lst> inline return_type eval(const Teller& tell, Lst&&... arg) { - static_assert(std::is_base_of_v<detail::teller, Teller>, "Teller is not evalueable."); return tell(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err; } |
