mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Migrated operators for floating_point
This commit is contained in:
parent
01d4ff6034
commit
7447363caa
@ -27,6 +27,8 @@
|
|||||||
#ifndef SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H
|
#ifndef SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H
|
||||||
#define 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/expression_operators.h>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
@ -37,52 +39,48 @@ namespace sqlpp
|
|||||||
template <typename Expr>
|
template <typename Expr>
|
||||||
struct expression_operators<Expr, floating_point> : public basic_expression_operators<Expr, floating_point>
|
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>
|
template <typename L, typename R>
|
||||||
plus_t<Expr, floating_point, wrap_operand_t<T>> operator+(T t) const
|
struct return_type_plus<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using check = consistent_t;
|
||||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
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>
|
template <typename L, typename R>
|
||||||
minus_t<Expr, floating_point, wrap_operand_t<T>> operator-(T t) const
|
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_floating_point_t, R, is_numeric_t>>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using check = consistent_t;
|
||||||
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
|
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>
|
template <typename T, typename Defer>
|
||||||
multiplies_t<Expr, floating_point, wrap_operand_t<T>> operator*(T t) const
|
struct return_type_unary_plus<T, Defer, unary_operand_check_t<T, is_floating_point_t>>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<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, typename Defer>
|
||||||
}
|
struct return_type_unary_minus<T, Defer, unary_operand_check_t<T, is_floating_point_t>>
|
||||||
|
{
|
||||||
template <typename T>
|
using check = consistent_t;
|
||||||
divides_t<Expr, wrap_operand_t<T>> operator/(T t) const
|
using type = unary_minus_t<floating_point, wrap_operand_t<T>>;
|
||||||
{
|
|
||||||
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)};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -92,17 +92,17 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename L, typename R>
|
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 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>
|
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 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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user