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

Migrated operators for floating_point

This commit is contained in:
rbock 2015-11-09 09:49:49 +01:00
parent 01d4ff6034
commit 7447363caa
2 changed files with 42 additions and 44 deletions

View File

@ -27,6 +27,8 @@
#ifndef SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H
#define SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H
#include <sqlpp11/expression_return_types.h>
#include <sqlpp11/operand_check.h>
#include <sqlpp11/expression_operators.h>
#include <sqlpp11/basic_expression_operators.h>
#include <sqlpp11/type_traits.h>
@ -37,52 +39,48 @@ namespace sqlpp
template <typename Expr>
struct expression_operators<Expr, floating_point> : public basic_expression_operators<Expr, floating_point>
{
template <typename T>
using _is_valid_operand = is_valid_operand<floating_point, T>;
};
template <typename T>
plus_t<Expr, floating_point, wrap_operand_t<T>> operator+(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
template <typename L, typename R>
struct return_type_plus<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
{
using check = consistent_t;
using type = plus_t<wrap_operand_t<L>, floating_point, wrap_operand_t<R>>;
};
return {*static_cast<const Expr*>(this), rhs{t}};
}
template <typename L, typename R>
struct return_type_minus<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
{
using check = consistent_t;
using type = minus_t<wrap_operand_t<L>, floating_point, wrap_operand_t<R>>;
};
template <typename T>
minus_t<Expr, floating_point, wrap_operand_t<T>> operator-(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
template <typename L, typename R>
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
{
using check = consistent_t;
using type = multiplies_t<wrap_operand_t<L>, floating_point, wrap_operand_t<R>>;
};
return {*static_cast<const Expr*>(this), rhs{t}};
}
template <typename L, typename R>
struct return_type_divides<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
{
using check = consistent_t;
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
};
template <typename T>
multiplies_t<Expr, floating_point, wrap_operand_t<T>> operator*(T t) const
{
using rhs = wrap_operand_t<T>;
template <typename T, typename Defer>
struct return_type_unary_plus<T, Defer, unary_operand_check_t<T, is_floating_point_t>>
{
using check = consistent_t;
using type = unary_plus_t<floating_point, wrap_operand_t<T>>;
};
return {*static_cast<const Expr*>(this), rhs{t}};
}
template <typename T>
divides_t<Expr, wrap_operand_t<T>> operator/(T t) const
{
using rhs = wrap_operand_t<T>;
return {*static_cast<const Expr*>(this), rhs{t}};
}
unary_plus_t<floating_point, Expr> operator+() const
{
return {*static_cast<const Expr*>(this)};
}
unary_minus_t<floating_point, Expr> operator-() const
{
return {*static_cast<const Expr*>(this)};
}
template <typename T, typename Defer>
struct return_type_unary_minus<T, Defer, unary_operand_check_t<T, is_floating_point_t>>
{
using check = consistent_t;
using type = unary_minus_t<floating_point, wrap_operand_t<T>>;
};
}
#endif

View File

@ -92,17 +92,17 @@ namespace sqlpp
};
template <typename L, typename R>
struct return_type_bitwise_and<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
struct return_type_bitwise_and<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_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>>;
using type = bitwise_and_t<wrap_operand_t<L>, integral, 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>>
struct return_type_bitwise_or<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_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>>;
using type = bitwise_or_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
};
}
#endif