From 7447363caaca7141ba0f75fc95a15d922a04a747 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 9 Nov 2015 09:49:49 +0100 Subject: [PATCH] Migrated operators for floating_point --- .../floating_point/expression_operators.h | 78 +++++++++---------- .../integral/expression_operators.h | 8 +- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/include/sqlpp11/data_types/floating_point/expression_operators.h b/include/sqlpp11/data_types/floating_point/expression_operators.h index e218fe98..1546b56c 100644 --- a/include/sqlpp11/data_types/floating_point/expression_operators.h +++ b/include/sqlpp11/data_types/floating_point/expression_operators.h @@ -27,6 +27,8 @@ #ifndef SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H #define SQLPP_FLOATING_POINT_EXPRESSION_OPERATORS_H +#include +#include #include #include #include @@ -37,52 +39,48 @@ namespace sqlpp template struct expression_operators : public basic_expression_operators { - template - using _is_valid_operand = is_valid_operand; + }; - template - plus_t> operator+(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); + template + struct return_type_plus> + { + using check = consistent_t; + using type = plus_t, floating_point, wrap_operand_t>; + }; - return {*static_cast(this), rhs{t}}; - } + template + struct return_type_minus> + { + using check = consistent_t; + using type = minus_t, floating_point, wrap_operand_t>; + }; - template - minus_t> operator-(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); + template + struct return_type_multiplies> + { + using check = consistent_t; + using type = multiplies_t, floating_point, wrap_operand_t>; + }; - return {*static_cast(this), rhs{t}}; - } + template + struct return_type_divides> + { + using check = consistent_t; + using type = divides_t, wrap_operand_t>; + }; - template - multiplies_t> operator*(T t) const - { - using rhs = wrap_operand_t; + template + struct return_type_unary_plus> + { + using check = consistent_t; + using type = unary_plus_t>; + }; - return {*static_cast(this), rhs{t}}; - } - - template - divides_t> operator/(T t) const - { - using rhs = wrap_operand_t; - - return {*static_cast(this), rhs{t}}; - } - - unary_plus_t operator+() const - { - return {*static_cast(this)}; - } - - unary_minus_t operator-() const - { - return {*static_cast(this)}; - } + template + struct return_type_unary_minus> + { + using check = consistent_t; + using type = unary_minus_t>; }; } #endif diff --git a/include/sqlpp11/data_types/integral/expression_operators.h b/include/sqlpp11/data_types/integral/expression_operators.h index c53da1b1..6d2ab170 100644 --- a/include/sqlpp11/data_types/integral/expression_operators.h +++ b/include/sqlpp11/data_types/integral/expression_operators.h @@ -92,17 +92,17 @@ namespace sqlpp }; template - struct return_type_bitwise_and> + struct return_type_bitwise_and> { using check = consistent_t; - using type = bitwise_and_t, value_type_of>, wrap_operand_t>; + using type = bitwise_and_t, integral, wrap_operand_t>; }; template - struct return_type_bitwise_or> + struct return_type_bitwise_or> { using check = consistent_t; - using type = bitwise_or_t, value_type_of>, wrap_operand_t>; + using type = bitwise_or_t, integral, wrap_operand_t>; }; } #endif