diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index 36557303..9ab73977 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -233,6 +233,20 @@ namespace sqlpp return {*static_cast(this), wrap_operand_t{r}}; } + template + auto operator&(const R& r) const -> return_type_bitwise_and_t + { + return_type_bitwise_and::check::_(); + return {*static_cast(this), wrap_operand_t{r}}; + } + + template + auto operator|(const R& r) const -> return_type_bitwise_or_t + { + return_type_bitwise_or::check::_(); + return {*static_cast(this), wrap_operand_t{r}}; + } + template auto operator or(const R& r) const -> return_type_or_t { @@ -268,6 +282,13 @@ namespace sqlpp return {*static_cast(this), wrap_operand_t{r}}; } + template + auto operator%(const R& r) const -> return_type_modulus_t + { + return_type_modulus::check::_(); + return {*static_cast(this), wrap_operand_t{r}}; + } + template auto operator+() const -> return_type_unary_plus_t { diff --git a/include/sqlpp11/data_types/integral/expression_operators.h b/include/sqlpp11/data_types/integral/expression_operators.h index ff41a908..c53da1b1 100644 --- a/include/sqlpp11/data_types/integral/expression_operators.h +++ b/include/sqlpp11/data_types/integral/expression_operators.h @@ -40,35 +40,6 @@ namespace sqlpp template struct expression_operators : public basic_expression_operators { - template - using _is_valid_operand = is_valid_operand; - - template - modulus_t> operator%(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); - - return {*static_cast(this), {t}}; - } - - template - bitwise_and_t, wrap_operand_t> operator&(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); - - return {*static_cast(this), {t}}; - } - - template - bitwise_or_t, wrap_operand_t> operator|(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); - - return {*static_cast(this), {t}}; - } }; template @@ -99,6 +70,13 @@ namespace sqlpp using type = divides_t, wrap_operand_t>; }; + template + struct return_type_modulus> + { + using check = consistent_t; + using type = modulus_t, wrap_operand_t>; + }; + template struct return_type_unary_plus> { @@ -112,5 +90,19 @@ namespace sqlpp using check = consistent_t; using type = unary_minus_t>; }; + + template + struct return_type_bitwise_and> + { + using check = consistent_t; + using type = bitwise_and_t, value_type_of>, wrap_operand_t>; + }; + + template + struct return_type_bitwise_or> + { + using check = consistent_t; + using type = bitwise_or_t, value_type_of>, wrap_operand_t>; + }; } #endif diff --git a/include/sqlpp11/expression_return_types.h b/include/sqlpp11/expression_return_types.h index dc64eaea..589a2839 100644 --- a/include/sqlpp11/expression_return_types.h +++ b/include/sqlpp11/expression_return_types.h @@ -37,27 +37,42 @@ namespace sqlpp using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_and_t = typename return_type_and::type; + template + struct return_type_bitwise_and + { + using check = assert_valid_operands; + using type = bad_expression; + }; + template + using return_type_bitwise_and_t = typename return_type_bitwise_and::type; + template struct return_type_or { using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_or_t = typename return_type_or::type; + template + struct return_type_bitwise_or + { + using check = assert_valid_operands; + using type = bad_expression; + }; + template + using return_type_bitwise_or_t = typename return_type_bitwise_or::type; + template struct return_type_not { using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_not_t = typename return_type_not::type; @@ -67,7 +82,6 @@ namespace sqlpp using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_plus_t = typename return_type_plus::type; @@ -77,7 +91,6 @@ namespace sqlpp using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_minus_t = typename return_type_minus::type; @@ -87,7 +100,6 @@ namespace sqlpp using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_multiplies_t = typename return_type_multiplies::type; @@ -97,17 +109,24 @@ namespace sqlpp using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_divides_t = typename return_type_divides::type; + template + struct return_type_modulus + { + using check = assert_valid_operands; + using type = bad_expression; + }; + template + using return_type_modulus_t = typename return_type_modulus::type; + template struct return_type_unary_plus { using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_unary_plus_t = typename return_type_unary_plus::type; @@ -117,7 +136,6 @@ namespace sqlpp using check = assert_valid_operands; using type = bad_expression; }; - template using return_type_unary_minus_t = typename return_type_unary_minus::type; }