0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Backported value_t

This commit is contained in:
Roland Bock 2021-09-07 10:14:35 +02:00
parent 085713d4d3
commit 4f99894cd4

View File

@ -32,12 +32,38 @@
namespace sqlpp
{
template <typename T>
auto value(T t) -> wrap_operand_t<T>
struct value_t : public wrap_operand_t<T>, public expression_operators<value_t<T>, value_type_of<wrap_operand_t<T>>>
{
using _base_t = wrap_operand_t<T>;
using _base_t::_base_t;
const _base_t& get_base() const
{
return *this;
}
};
template <typename T>
auto value(T t) -> value_t<T>
{
static_assert(is_wrapped_value_t<wrap_operand_t<T>>::value,
"value() is to be called with non-sql-type like int, or string");
return {t};
}
template <typename Context, typename T>
struct serializer_t<Context, value_t<T>>
{
using _serialize_check = consistent_t;
using Operand = value_t<T>;
static Context& _(const Operand& t, Context& context)
{
serialize(t.get_base(), context);
return context;
}
};
} // namespace sqlpp
#endif