|
8 | 8 |
|
9 | 9 | namespace sqlite {
|
10 | 10 | 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 {}; |
11 | 17 | template<class Functor, class ...Functors>
|
12 | 18 | class FunctorOverload: public Functor, public FunctorOverload<Functors...> {
|
13 | 19 | public:
|
@@ -43,23 +49,23 @@ namespace sqlite {
|
43 | 49 | };
|
44 | 50 | }
|
45 | 51 | 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 |
47 | 53 | error_log(Handler &&handler);
|
48 | 54 | 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 |
50 | 56 | error_log(Handler &&handler);
|
51 | 57 | template<class ...Handler>
|
52 | 58 | typename std::enable_if<sizeof...(Handler)>=2>::type
|
53 | 59 | error_log(Handler &&...handler) {
|
54 | 60 | return error_log(detail::FunctorOverload<detail::WrapIntoFunctor<typename std::decay<Handler>::type>...>(std::forward<Handler>(handler)...));
|
55 | 61 | }
|
56 | 62 | 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 |
58 | 64 | error_log(Handler &&handler) {
|
59 | 65 | return error_log(std::forward<Handler>(handler), [](const sqlite_exception&) {});
|
60 | 66 | }
|
61 | 67 | 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 |
63 | 69 | error_log(Handler &&handler) {
|
64 | 70 | auto ptr = new auto([handler = std::forward<Handler>(handler)](int error_code, const char *errstr) mutable {
|
65 | 71 | switch(error_code & 0xFF) {
|
|
0 commit comments