summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/column.cpp19
-rw-r--r--libdbpp/selectcommandUtil.impl.h21
-rw-r--r--libdbpp/testCore.cpp19
3 files changed, 26 insertions, 33 deletions
diff --git a/libdbpp/column.cpp b/libdbpp/column.cpp
index f8eae65..b660cd3 100644
--- a/libdbpp/column.cpp
+++ b/libdbpp/column.cpp
@@ -1,5 +1,4 @@
#include "column.h"
-#include <boost/utility/enable_if.hpp>
#include <exception>
#include <compileTimeFormatter.h>
@@ -43,16 +42,14 @@ class Extract : public DB::HandleField {
void blob(const Blob & v) override { (*this)(v); }
void null() override { }
- template <typename D, typename dummy = int>
- void operator()(const D &,
- typename boost::disable_if<std::is_convertible<D, T>, dummy>::type = 0) {
- throw InvalidConversion(typeid(D).name(), typeid(T).name());
- }
-
- template <typename D, typename dummy = int>
- void operator()(const D & v,
- typename boost::enable_if<std::is_convertible<D, T>, dummy>::type = 0) {
- target = (T)v;
+ template <typename D>
+ void operator()(const D & v) {
+ if constexpr (std::is_convertible<D, T>::value) {
+ target = (T)v;
+ }
+ else {
+ throw InvalidConversion(typeid(D).name(), typeid(T).name());
+ }
}
T & target;
diff --git a/libdbpp/selectcommandUtil.impl.h b/libdbpp/selectcommandUtil.impl.h
index dfe6894..6446de0 100644
--- a/libdbpp/selectcommandUtil.impl.h
+++ b/libdbpp/selectcommandUtil.impl.h
@@ -6,20 +6,19 @@
/// @cond
namespace DB {
- template<typename Fields, typename Func, unsigned int field, typename ... Fn>
- inline typename std::enable_if<field >= std::tuple_size<Fields>::value>::type
- forEachField(DB::SelectCommand *, const Func & func, const Fn & ... args)
- {
- func(args...);
- }
-
template<typename Fields, typename Func, unsigned int field, typename ... Fn, typename ... Args>
- inline typename std::enable_if<field < std::tuple_size<Fields>::value>::type
+ inline void
forEachField(DB::SelectCommand * sel, const Func & func, const Args & ... args)
{
- typename std::tuple_element<field, Fields>::type a;
- (*sel)[field] >> a;
- forEachField<Fields, Func, field + 1, Fn...>(sel, func, args..., a);
+ if constexpr (field >= std::tuple_size<Fields>::value) {
+ (void)sel;
+ func(args...);
+ }
+ else {
+ typename std::tuple_element<field, Fields>::type a;
+ (*sel)[field] >> a;
+ forEachField<Fields, Func, field + 1, Fn...>(sel, func, args..., a);
+ }
}
template<typename ... Fn, typename Func>
diff --git a/libdbpp/testCore.cpp b/libdbpp/testCore.cpp
index 890cb18..b55d16d 100644
--- a/libdbpp/testCore.cpp
+++ b/libdbpp/testCore.cpp
@@ -2,7 +2,6 @@
#include <selectcommand.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/test/test_tools.hpp>
-#include <boost/utility/enable_if.hpp>
#include <compileTimeFormatter.h>
namespace DB {
@@ -31,16 +30,14 @@ class Assert : public DB::HandleField {
void blob(const Blob & v) override { (*this)(v); }
void null() override { }
- template <typename D, typename dummy = int>
- void operator()(const D &,
- typename boost::disable_if<std::is_convertible<D, T>, dummy>::type = 0) {
- BOOST_ERROR("Unexpected column type " << typeid(D).name());
- }
-
- template <typename D, typename dummy = int>
- void operator()(const D & v,
- typename boost::enable_if<std::is_convertible<D, T>, dummy>::type = 0) {
- BOOST_REQUIRE_EQUAL(expected, v);
+ template <typename D>
+ void operator()(const D & v) {
+ if constexpr (std::is_convertible<D, T>::value) {
+ BOOST_REQUIRE_EQUAL(expected, v);
+ }
+ else {
+ BOOST_ERROR("Unexpected column type " << typeid(D).name());
+ }
}
const T & expected;