From 8440baf12e9a83d814c5a117c17772ccf951c713 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 19 Oct 2016 21:25:46 +0100 Subject: Add extra enable_if filter to check *o is a thing and test case of issues found compiling slicer --- libdbpp/command.h | 7 ++++++- libdbpp/unittests/testUtils.cpp | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libdbpp/command.h b/libdbpp/command.h index 8fbff4e..d9bc853 100644 --- a/libdbpp/command.h +++ b/libdbpp/command.h @@ -65,7 +65,12 @@ namespace DB { #define OPTWRAPPER(func) \ template \ - inline typename std::enable_if::value>::type func(unsigned int i, const O & o) { \ + inline auto \ + func(unsigned int i, const O & o) -> typename std::enable_if< \ + std::is_constructible::value \ + && !std::is_void::value \ + >::type\ + { \ bool nn(o); \ if (nn) \ func(i, *o); \ diff --git a/libdbpp/unittests/testUtils.cpp b/libdbpp/unittests/testUtils.cpp index cb660cc..1435ad3 100644 --- a/libdbpp/unittests/testUtils.cpp +++ b/libdbpp/unittests/testUtils.cpp @@ -219,6 +219,15 @@ BOOST_AUTO_TEST_CASE( charStarBindNull ) } } +BOOST_AUTO_TEST_CASE( bind ) +{ + auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock")); + auto m = db->modify("doesn't matter, only testing compile"); + m->bindParamI(0, (unsigned char)1); + m->bindParamI(0, (char)1); + m->bindParamI(0, (time_t)1); +} + BOOST_AUTO_TEST_CASE( bindIntPtr ) { auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock")); -- cgit v1.2.3