Skip to content

Instantly share code, notes, and snippets.

@Chippiewill
Last active December 30, 2016 06:54
Show Gist options
  • Save Chippiewill/37da1fc0849f43edb33d67191e7fd374 to your computer and use it in GitHub Desktop.
Save Chippiewill/37da1fc0849f43edb33d67191e7fd374 to your computer and use it in GitHub Desktop.
diff --git a/include/memcached/engine_error.h b/include/memcached/engine_error.h
index fafcb44..e97003c 100644
--- a/include/memcached/engine_error.h
+++ b/include/memcached/engine_error.h
@@ -93,6 +93,10 @@ public:
: system_error(int(ev), engine_error_category(), what_arg) {}
};
+static inline std::error_condition make_error_condition(cb::engine_errc e) NOEXCEPT {
+ return std::error_condition(int(e), cb::engine_error_category());
+}
+
}
// For backwards compatibility with the old memcached source code we need
@@ -121,13 +125,8 @@ typedef enum {
ENGINE_FAILED = int(cb::engine_errc::failed),
} ENGINE_ERROR_CODE;
-
namespace std {
-static inline error_condition make_error_condition(cb::engine_errc e) {
- return error_condition(int(e), cb::engine_error_category());
-}
-
template <>
-struct is_error_code_enum<cb::engine_errc> : public true_type { };
+struct is_error_condition_enum<cb::engine_errc> : public true_type { };
}
diff --git a/tests/engine_error/engine_error_test.cc b/tests/engine_error/engine_error_test.cc
index b54f15e..d255509 100644
--- a/tests/engine_error/engine_error_test.cc
+++ b/tests/engine_error/engine_error_test.cc
@@ -38,8 +38,7 @@ TEST(EngineError, test_invalid_value) {
TEST(EngineError, test_engine_error_with_scoped_enums) {
cb::engine_error error(cb::engine_errc::no_memory, "foo");
- EXPECT_EQ(cb::engine_errc::no_memory,
- cb::engine_errc(error.code().value()));
+ EXPECT_EQ(cb::engine_errc::no_memory, error.code());
EXPECT_STREQ("engine error codes", error.code().category().name());
EXPECT_STREQ("foo: no memory", error.what());
}
@@ -48,7 +47,7 @@ TEST(EngineError, test_system_error) {
try {
throw cb::engine_error(cb::engine_errc::no_memory, "foo");
} catch (const std::system_error& error) {
- EXPECT_EQ(int(cb::engine_errc::no_memory), error.code().value());
+ EXPECT_EQ(cb::engine_errc::no_memory, error.code());
EXPECT_STREQ("engine error codes", error.code().category().name());
EXPECT_STREQ("foo: no memory", error.what());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment