0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Moved operators back into expression base class

This commit is contained in:
rbock 2015-11-08 19:14:49 +01:00
parent 5556880bb9
commit 29bf1529e4
10 changed files with 34 additions and 13 deletions

View File

@ -218,6 +218,27 @@ namespace sqlpp
check_rhs_in_arguments_t<ValueType, wrap_operand_t<T>...>::_();
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
}
template <typename Defer = void>
auto operator not() const -> return_type_not_t<Expr, Defer>
{
return_type_not<Expr, Defer>::check::_();
return {*static_cast<const Expr*>(this)};
}
template <typename R>
auto operator and(const R& r) const -> return_type_and_t<Expr, R>
{
return_type_and<Expr, R>::check::_();
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
template <typename R>
auto operator or(const R& r) const -> return_type_or_t<Expr, R>
{
return_type_or<Expr, R>::check::_();
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
};
}

View File

@ -33,7 +33,7 @@ namespace sqlpp
{
struct boolean
{
// using _traits = make_traits<void, tag::is_value_type>;
using _traits = make_traits<boolean, tag::is_value_type>;
using _cpp_value_type = bool;
template <typename T>

View File

@ -27,7 +27,7 @@
#ifndef SQLPP_BOOLEAN_EXPRESSION_OPERATORS_H
#define SQLPP_BOOLEAN_EXPRESSION_OPERATORS_H
#include <sqlpp11/operators.h>
//#include <sqlpp11/operators.h>
#include <sqlpp11/expression_return_types.h>
#include <sqlpp11/operand_check.h>
#include <sqlpp11/expression_operators.h>
@ -54,8 +54,8 @@ namespace sqlpp
using type = logical_or_t<wrap_operand_t<L>, wrap_operand_t<R>>;
};
template <typename T>
struct return_type_not<T, unary_operand_check_t<T, is_boolean_t>>
template <typename T, typename Defer>
struct return_type_not<T, Defer, unary_operand_check_t<T, is_boolean_t>>
{
using check = consistent_t;
using type = logical_not_t<wrap_operand_t<T>>;

View File

@ -34,7 +34,7 @@ namespace sqlpp
{
struct day_point
{
using _traits = make_traits<void, tag::is_value_type>;
using _traits = make_traits<day_point, tag::is_value_type>;
using _cpp_value_type = ::sqlpp::chrono::day_point;
template <typename T>

View File

@ -33,7 +33,7 @@ namespace sqlpp
{
struct floating_point
{
using _traits = make_traits<void, tag::is_value_type>;
using _traits = make_traits<floating_point, tag::is_value_type>;
using _cpp_value_type = double;
template <typename T>

View File

@ -33,7 +33,7 @@ namespace sqlpp
{
struct integral
{
using _traits = make_traits<void, tag::is_value_type>;
using _traits = make_traits<integral, tag::is_value_type>;
using _cpp_value_type = int64_t;
template <typename T>

View File

@ -33,7 +33,7 @@ namespace sqlpp
{
struct text
{
using _traits = make_traits<void, tag::is_value_type>;
using _traits = make_traits<text, tag::is_value_type>;
using _cpp_value_type = std::string;
template <typename T>

View File

@ -34,7 +34,7 @@ namespace sqlpp
{
struct time_point
{
using _traits = make_traits<void, tag::is_value_type>;
using _traits = make_traits<time_point, tag::is_value_type>;
using _cpp_value_type = ::sqlpp::chrono::mus_point;
template <typename T>

View File

@ -51,15 +51,15 @@ namespace sqlpp
template <typename L, typename R>
using return_type_or_t = typename return_type_or<L, R>::type;
template <typename T, typename Enable = void>
template <typename T, typename Defer, typename Enable = void>
struct return_type_not
{
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename T>
using return_type_not_t = typename return_type_not<T>::type;
template <typename T, typename Defer>
using return_type_not_t = typename return_type_not<T, Defer>::type;
}
#endif

View File

@ -35,7 +35,7 @@ int BooleanExpression(int, char**)
auto x = boolean_expression(db, not(t.alpha == 7));
x = sqlpp::boolean_expression<MockDb>(t.beta.like("%cheesecake"));
x = false or (x and boolean_expression(db, t.gamma));
x = x and boolean_expression(db, t.gamma);
db(select(t.alpha).from(t).where(x));