mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Introduced unary function templates which use one pair of braces less
This is required for sqlite which cannot parse SELECT EXISTS((SELECT 1))
This commit is contained in:
parent
d55cfce746
commit
c042d99643
@ -315,6 +315,38 @@ namespace sqlpp
|
||||
std::tuple<Rhs...> _rhs;
|
||||
};
|
||||
|
||||
template<typename F, typename Rhs>
|
||||
struct unary_function_t: public F::_value_type::template operators<unary_function_t<F, Rhs>>
|
||||
{
|
||||
using _value_type = typename F::_value_type;
|
||||
|
||||
unary_function_t(Rhs&& r):
|
||||
_rhs(std::move(r))
|
||||
{}
|
||||
|
||||
unary_function_t(const Rhs& r):
|
||||
_rhs(r)
|
||||
{}
|
||||
|
||||
unary_function_t(const unary_function_t&) = default;
|
||||
unary_function_t(unary_function_t&&) = default;
|
||||
unary_function_t& operator=(const unary_function_t&) = default;
|
||||
unary_function_t& operator=(unary_function_t&&) = default;
|
||||
~unary_function_t() = default;
|
||||
|
||||
template<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
os << F::_name;
|
||||
os << "(";
|
||||
_rhs.serialize(os, db);
|
||||
os << ")";
|
||||
}
|
||||
|
||||
private:
|
||||
Rhs _rhs;
|
||||
};
|
||||
|
||||
template<typename F, typename... Rhs>
|
||||
struct named_nary_function_t: public F::_value_type::template operators<named_nary_function_t<F, Rhs...>>
|
||||
{
|
||||
@ -347,6 +379,39 @@ namespace sqlpp
|
||||
private:
|
||||
std::tuple<Rhs...> _rhs;
|
||||
};
|
||||
|
||||
template<typename F, typename Rhs>
|
||||
struct named_unary_function_t: public F::_value_type::template operators<named_unary_function_t<F, Rhs>>
|
||||
{
|
||||
using _value_type = typename F::_value_type;
|
||||
using _name_t = typename F::_name_t;
|
||||
|
||||
named_unary_function_t(Rhs&& r):
|
||||
_rhs(std::move(r))
|
||||
{}
|
||||
|
||||
named_unary_function_t(const Rhs& r):
|
||||
_rhs(r)
|
||||
{}
|
||||
|
||||
named_unary_function_t(const named_unary_function_t&) = default;
|
||||
named_unary_function_t(named_unary_function_t&&) = default;
|
||||
named_unary_function_t& operator=(const named_unary_function_t&) = default;
|
||||
named_unary_function_t& operator=(named_unary_function_t&&) = default;
|
||||
~named_unary_function_t() = default;
|
||||
|
||||
template<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
{
|
||||
os << F::_name_t::_get_name();
|
||||
os << "(";
|
||||
_rhs.serialize(os, db);
|
||||
os << ")";
|
||||
}
|
||||
|
||||
private:
|
||||
Rhs _rhs;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -60,7 +60,7 @@ namespace sqlpp
|
||||
};\
|
||||
};\
|
||||
\
|
||||
using type = named_nary_function_t<_op, _operand>;\
|
||||
using type = named_unary_function_t<_op, _operand>;\
|
||||
};\
|
||||
}\
|
||||
template<typename T>\
|
||||
|
Loading…
Reference in New Issue
Block a user