summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-10-19 21:25:46 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-10-21 23:17:36 +0100
commit8440baf12e9a83d814c5a117c17772ccf951c713 (patch)
tree09f5f136c84e998e21f113f6eb09d19c72f0e4d3
parentAdd enable_if to catch some conversion madness (diff)
downloadlibdbpp-1.0.4.tar.bz2
libdbpp-1.0.4.tar.xz
libdbpp-1.0.4.zip
Add extra enable_if filter to check *o is a thing and test case of issues found compiling slicerlibdbpp-1.0.4
-rw-r--r--libdbpp/command.h7
-rw-r--r--libdbpp/unittests/testUtils.cpp9
2 files changed, 15 insertions, 1 deletions
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<typename O> \
- inline typename std::enable_if<std::is_constructible<bool, const O &>::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<bool, const O &>::value \
+ && !std::is_void<decltype(*o)>::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"));