Skip to content

Commit c03d4c8

Browse files
committed
Fix for C++14
1 parent cb29f13 commit c03d4c8

File tree

1 file changed

+10
-4
lines changed
  • hdr/sqlite_modern_cpp

1 file changed

+10
-4
lines changed

hdr/sqlite_modern_cpp/log.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
namespace sqlite {
1010
namespace detail {
11+
template<class>
12+
using void_t = void;
13+
template<class T, class = void>
14+
struct is_callable : std::false_type {};
15+
template<class Functor, class ...Arguments>
16+
struct is_callable<Functor(Arguments...), void_t<decltype(std::declval<Functor>()(std::declval<Arguments>()...))>> : std::true_type {};
1117
template<class Functor, class ...Functors>
1218
class FunctorOverload: public Functor, public FunctorOverload<Functors...> {
1319
public:
@@ -43,23 +49,23 @@ namespace sqlite {
4349
};
4450
}
4551
template<class Handler>
46-
typename std::enable_if<!std::is_callable<Handler(const sqlite_exception&)>::value>::type
52+
typename std::enable_if<!detail::is_callable<Handler(const sqlite_exception&)>::value>::type
4753
error_log(Handler &&handler);
4854
template<class Handler>
49-
typename std::enable_if<std::is_callable<Handler(const sqlite_exception&)>::value>::type
55+
typename std::enable_if<detail::is_callable<Handler(const sqlite_exception&)>::value>::type
5056
error_log(Handler &&handler);
5157
template<class ...Handler>
5258
typename std::enable_if<sizeof...(Handler)>=2>::type
5359
error_log(Handler &&...handler) {
5460
return error_log(detail::FunctorOverload<detail::WrapIntoFunctor<typename std::decay<Handler>::type>...>(std::forward<Handler>(handler)...));
5561
}
5662
template<class Handler>
57-
typename std::enable_if<!std::is_callable<Handler(const sqlite_exception&)>::value>::type
63+
typename std::enable_if<!detail::is_callable<Handler(const sqlite_exception&)>::value>::type
5864
error_log(Handler &&handler) {
5965
return error_log(std::forward<Handler>(handler), [](const sqlite_exception&) {});
6066
}
6167
template<class Handler>
62-
typename std::enable_if<std::is_callable<Handler(const sqlite_exception&)>::value>::type
68+
typename std::enable_if<detail::is_callable<Handler(const sqlite_exception&)>::value>::type
6369
error_log(Handler &&handler) {
6470
auto ptr = new auto([handler = std::forward<Handler>(handler)](int error_code, const char *errstr) mutable {
6571
switch(error_code & 0xFF) {

0 commit comments

Comments
 (0)