Commit 4dd595da authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

SqliteTools: Properly implement Traits using SFINAE

parent 6374a13e
......@@ -11,18 +11,17 @@
#include "Types.h"
// Have a base case for integral type only
// Use specialization to define other cases, and fail for the rest.
template <typename T, typename Enable = void>
struct Traits;
template <typename T>
struct Traits
struct Traits<T, typename std::enable_if<std::is_integral<T>::value>::type>
{
static constexpr
typename std::enable_if<std::is_integral<T>::value, int>::type
(*Bind)(sqlite3_stmt *, int, int) = &sqlite3_bind_int;
int (*Bind)(sqlite3_stmt *, int, int) = &sqlite3_bind_int;
static constexpr
typename std::enable_if<std::is_integral<T>::value, int>::type
(*Load)(sqlite3_stmt *, int) = &sqlite3_column_int;
int (*Load)(sqlite3_stmt *, int) = &sqlite3_column_int;
};
template <>
......@@ -43,8 +42,8 @@ struct Traits<std::string>
}
};
template <>
struct Traits<float>
template <typename T>
struct Traits<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
{
static constexpr int
(*Bind)(sqlite3_stmt *, int, double) = &sqlite3_bind_double;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment