From d0572297f1a165ed9c39a60d430c7590ef8173d6 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 30 Mar 2020 22:51:37 -0300 Subject: [PATCH] Fix compilation failure on old gcc, avoid compiler warnings std::underlying_type isn't allowed to be used unless you already know the type is an enum (until C++20), and causes a compilation failure if used (even after the boolean check) on gcc 8 and below. The bind_blob and bind_text taking over ownership might be useful, but currently aren't used so just comment them out so if someone develops a need they are ready to go. --- src/cryptonote_core/loki_name_system.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/loki_name_system.cpp b/src/cryptonote_core/loki_name_system.cpp index 80de6605d..6755d6706 100644 --- a/src/cryptonote_core/loki_name_system.cpp +++ b/src/cryptonote_core/loki_name_system.cpp @@ -180,6 +180,7 @@ bool bind(sql_compiled_statement& s, int index, lokimq::string_view text) return SQLITE_OK == sqlite3_bind_text(s.statement, index, text.data(), text.size(), nullptr /*dtor*/); } +/* Currently unused; comment out until needed to avoid a compiler warning // text, from a temporary std::string; ownership of the string data is transferred to sqlite3 bool bind(sql_compiled_statement& s, int index, std::string&& text) { @@ -191,11 +192,13 @@ bool bind(sql_compiled_statement& s, int index, std::string&& text) delete local_text; return false; } +*/ template struct is_int_enum : std::false_type {}; template -struct is_int_enum::value && std::is_same, int>::value>> : std::true_type {}; +struct is_int_enum::value>> +: std::integral_constant, int>::value> {}; // Binds, but gives index as an enum class template ::value, int> = 0> @@ -218,6 +221,7 @@ bool bind_blob(sql_compiled_statement& s, int index, lokimq::string_view blob) return SQLITE_OK == sqlite3_bind_blob(s.statement, index, blob.data(), blob.size(), nullptr /*dtor*/); } +/* Currently unused; comment out until needed to avoid a compiler warning // From a std::string rvalue; sqlite3 manages ownership bool bind_blob(sql_compiled_statement& s, int index, std::string&& blob) { @@ -229,6 +233,7 @@ bool bind_blob(sql_compiled_statement& s, int index, std::string&& blob) delete local_blob; return false; } +*/ // Wrapper for bind_blob with an enum index template ::value, int> = 0>