mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 22:17:02 +07:00
fast error_code access from uerror
This commit is contained in:
@@ -3,7 +3,7 @@ add_library(${PROJECT_NAME}::setup_targets ALIAS ${PROJECT_NAME}.setup_targets)
|
|||||||
|
|
||||||
target_compile_options(${PROJECT_NAME}.setup_targets INTERFACE
|
target_compile_options(${PROJECT_NAME}.setup_targets INTERFACE
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:
|
$<$<CXX_COMPILER_ID:MSVC>:
|
||||||
/WX /W4>
|
/WX /W4 /bigobj>
|
||||||
$<$<CXX_COMPILER_ID:GNU>:
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
-Werror -Wall -Wextra -Wpedantic>
|
-Werror -Wall -Wextra -Wpedantic>
|
||||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||||
|
|||||||
@@ -28,24 +28,29 @@ TEST_CASE("meta/meta_utilities/uerror") {
|
|||||||
SUBCASE("ctors") {
|
SUBCASE("ctors") {
|
||||||
{
|
{
|
||||||
meta::uerror err{};
|
meta::uerror err{};
|
||||||
|
CHECK(*err == meta::error_code::no_error);
|
||||||
CHECK(err.get_error() == meta::error_code::no_error);
|
CHECK(err.get_error() == meta::error_code::no_error);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
meta::uerror err{meta::error_code::bad_argument_cast};
|
meta::uerror err{meta::error_code::bad_argument_cast};
|
||||||
|
CHECK(*err == meta::error_code::bad_argument_cast);
|
||||||
CHECK(err.get_error() == meta::error_code::bad_argument_cast);
|
CHECK(err.get_error() == meta::error_code::bad_argument_cast);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
meta::uerror err{meta::error_code::bad_instance_cast};
|
meta::uerror err{meta::error_code::bad_instance_cast};
|
||||||
|
CHECK(*err == meta::error_code::bad_instance_cast);
|
||||||
CHECK(err.get_error() == meta::error_code::bad_instance_cast);
|
CHECK(err.get_error() == meta::error_code::bad_instance_cast);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
meta::uerror err1{meta::error_code::bad_argument_cast};
|
meta::uerror err1{meta::error_code::bad_argument_cast};
|
||||||
meta::uerror err2{err1};
|
meta::uerror err2{err1};
|
||||||
|
CHECK(*err2 == meta::error_code::bad_argument_cast);
|
||||||
CHECK(err2.get_error() == meta::error_code::bad_argument_cast);
|
CHECK(err2.get_error() == meta::error_code::bad_argument_cast);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
meta::uerror err1{meta::error_code::bad_argument_cast};
|
meta::uerror err1{meta::error_code::bad_argument_cast};
|
||||||
meta::uerror err2{std::move(err1)};
|
meta::uerror err2{std::move(err1)};
|
||||||
|
CHECK(*err2 == meta::error_code::bad_argument_cast);
|
||||||
CHECK(err2.get_error() == meta::error_code::bad_argument_cast);
|
CHECK(err2.get_error() == meta::error_code::bad_argument_cast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace meta_hpp
|
|||||||
[[nodiscard]] bool has_error() const noexcept;
|
[[nodiscard]] bool has_error() const noexcept;
|
||||||
[[nodiscard]] explicit operator bool() const noexcept;
|
[[nodiscard]] explicit operator bool() const noexcept;
|
||||||
|
|
||||||
|
[[nodiscard]] error_code operator*() const noexcept;
|
||||||
[[nodiscard]] error_code get_error() const noexcept;
|
[[nodiscard]] error_code get_error() const noexcept;
|
||||||
|
|
||||||
void reset() noexcept;
|
void reset() noexcept;
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ namespace meta_hpp
|
|||||||
return has_error();
|
return has_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline error_code uerror::operator*() const noexcept {
|
||||||
|
return error_;
|
||||||
|
}
|
||||||
|
|
||||||
inline error_code uerror::get_error() const noexcept {
|
inline error_code uerror::get_error() const noexcept {
|
||||||
return error_;
|
return error_;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user