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

Migrated remaining integral operators

This commit is contained in:
rbock 2015-11-09 07:40:21 +01:00
parent 93d89ff705
commit 01d4ff6034
3 changed files with 69 additions and 38 deletions

View File

@ -233,6 +233,20 @@ namespace sqlpp
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
template <typename R>
auto operator&(const R& r) const -> return_type_bitwise_and_t<Expr, R>
{
return_type_bitwise_and<Expr, R>::check::_();
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
template <typename R>
auto operator|(const R& r) const -> return_type_bitwise_or_t<Expr, R>
{
return_type_bitwise_or<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>
{
@ -268,6 +282,13 @@ namespace sqlpp
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
template <typename R>
auto operator%(const R& r) const -> return_type_modulus_t<Expr, R>
{
return_type_modulus<Expr, R>::check::_();
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
template <typename Defer = void>
auto operator+() const -> return_type_unary_plus_t<Expr, Defer>
{

View File

@ -40,35 +40,6 @@ namespace sqlpp
template <typename Expression>
struct expression_operators<Expression, integral> : public basic_expression_operators<Expression, integral>
{
template <typename T>
using _is_valid_operand = is_valid_operand<integral, T>;
template <typename T>
modulus_t<Expression, wrap_operand_t<T>> operator%(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
return {*static_cast<const Expression*>(this), {t}};
}
template <typename T>
bitwise_and_t<Expression, value_type_t<T>, wrap_operand_t<T>> operator&(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
return {*static_cast<const Expression*>(this), {t}};
}
template <typename T>
bitwise_or_t<Expression, value_type_t<T>, wrap_operand_t<T>> operator|(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
return {*static_cast<const Expression*>(this), {t}};
}
};
template <typename L, typename R>
@ -99,6 +70,13 @@ namespace sqlpp
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
};
template <typename L, typename R>
struct return_type_modulus<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_t>>
{
using check = consistent_t;
using type = modulus_t<wrap_operand_t<L>, wrap_operand_t<R>>;
};
template <typename T, typename Defer>
struct return_type_unary_plus<T, Defer, unary_operand_check_t<T, is_integral_t>>
{
@ -112,5 +90,19 @@ namespace sqlpp
using check = consistent_t;
using type = unary_minus_t<integral, wrap_operand_t<T>>;
};
template <typename L, typename R>
struct return_type_bitwise_and<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
{
using check = consistent_t;
using type = bitwise_and_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
};
template <typename L, typename R>
struct return_type_bitwise_or<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
{
using check = consistent_t;
using type = bitwise_or_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
};
}
#endif

View File

@ -37,27 +37,42 @@ namespace sqlpp
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_and_t = typename return_type_and<L, R>::type;
template <typename L, typename R, typename Enable = void>
struct return_type_bitwise_and
{
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_bitwise_and_t = typename return_type_bitwise_and<L, R>::type;
template <typename L, typename R, typename Enable = void>
struct return_type_or
{
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_or_t = typename return_type_or<L, R>::type;
template <typename L, typename R, typename Enable = void>
struct return_type_bitwise_or
{
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_bitwise_or_t = typename return_type_bitwise_or<L, R>::type;
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, typename Defer>
using return_type_not_t = typename return_type_not<T, Defer>::type;
@ -67,7 +82,6 @@ namespace sqlpp
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_plus_t = typename return_type_plus<L, R>::type;
@ -77,7 +91,6 @@ namespace sqlpp
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_minus_t = typename return_type_minus<L, R>::type;
@ -87,7 +100,6 @@ namespace sqlpp
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_multiplies_t = typename return_type_multiplies<L, R>::type;
@ -97,17 +109,24 @@ namespace sqlpp
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_divides_t = typename return_type_divides<L, R>::type;
template <typename L, typename R, typename Enable = void>
struct return_type_modulus
{
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename L, typename R>
using return_type_modulus_t = typename return_type_modulus<L, R>::type;
template <typename T, typename Defer, typename Enable = void>
struct return_type_unary_plus
{
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename T, typename Defer>
using return_type_unary_plus_t = typename return_type_unary_plus<T, Defer>::type;
@ -117,7 +136,6 @@ namespace sqlpp
using check = assert_valid_operands;
using type = bad_expression<boolean>;
};
template <typename T, typename Defer>
using return_type_unary_minus_t = typename return_type_unary_minus<T, Defer>::type;
}