Commit 917668a6 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Sqlite: Traits: Support load/bind of atomic values

parent add3f468
......@@ -24,6 +24,8 @@
#include <sqlite3.h>
#include <tuple>
#include <atomic>
#include <utility>
namespace medialibrary
{
......@@ -210,7 +212,6 @@ public:
}
};
// Provide a specialization for empty tuples
template <typename T>
struct Traits<T, typename std::enable_if<
......@@ -227,6 +228,28 @@ struct Traits<T, typename std::enable_if<
}
};
template <typename T>
struct Traits<T, typename std::enable_if<
is_instanciation_of<typename std::decay<T>::type, std::atomic>::value>::type
>
{
// std::atomic::value_type is C++17 only
using value_type = decltype( std::declval<T>().load() );
static int Bind( sqlite3_stmt* stmt, int pos, const T& value )
{
return Traits<value_type>::Bind( stmt, pos, value.load() );
}
static value_type Load( sqlite3_stmt* stmt, int pos )
{
return Traits<value_type>::Load( stmt, pos );
}
};
static_assert( is_instanciation_of<std::atomic_uint, std::atomic>::value == true,
"std::atomic_uint should be an instanciation of std::atomic" );
} // namespace sqlite
}
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