diff --git a/include/sqlpp11/avg.h b/include/sqlpp11/avg.h index 8e3baaf5..27a61bcf 100644 --- a/include/sqlpp11/avg.h +++ b/include/sqlpp11/avg.h @@ -32,8 +32,9 @@ namespace sqlpp { template - struct avg_t: public floating_point::template expression_operators>, - public alias_operators> + struct avg_t: + public expression_operators, floating_point>, + public alias_operators> { using _traits = make_traits; using _recursive_traits = make_recursive_traits; diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index 7c7d3ec8..e3bfb5e4 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -27,6 +27,7 @@ #ifndef SQLPP_DETAIL_BASIC_EXPRESSION_OPERATORS_H #define SQLPP_DETAIL_BASIC_EXPRESSION_OPERATORS_H +#include #include #include #include @@ -38,7 +39,7 @@ namespace sqlpp { // basic operators - template class IsCorrectValueType> + template struct basic_expression_operators { template @@ -47,107 +48,107 @@ namespace sqlpp static constexpr bool value = (is_expression_t::value // expressions are OK or is_multi_expression_t::value) // multi-expressions like ANY are OK for comparisons, too - and IsCorrectValueType::value // the correct value type is required, of course + and ValueType::template _is_valid_operand::value // the correct value type is required, of course ; }; template - equal_to_t> operator==(T t) const + equal_to_t> operator==(T t) const { using rhs = wrap_operand_t; static_assert(_is_valid_comparison_operand::value, "invalid rhs operand in comparison"); - return { *static_cast(this), {rhs{t}} }; + return { *static_cast(this), {rhs{t}} }; } template - not_equal_to_t> operator!=(T t) const + not_equal_to_t> operator!=(T t) const { using rhs = wrap_operand_t; static_assert(_is_valid_comparison_operand::value, "invalid rhs operand in comparison"); - return { *static_cast(this), {rhs{t}} }; + return { *static_cast(this), {rhs{t}} }; } template - less_than_t> operator<(T t) const + less_than_t> operator<(T t) const { using rhs = wrap_operand_t; static_assert(_is_valid_comparison_operand::value, "invalid rhs operand in comparison"); - return { *static_cast(this), rhs{t} }; + return { *static_cast(this), rhs{t} }; } template - less_equal_t> operator<=(T t) const + less_equal_t> operator<=(T t) const { using rhs = wrap_operand_t; static_assert(_is_valid_comparison_operand::value, "invalid rhs operand in comparison"); - return { *static_cast(this), rhs{t} }; + return { *static_cast(this), rhs{t} }; } template - greater_than_t> operator>(T t) const + greater_than_t> operator>(T t) const { using rhs = wrap_operand_t; static_assert(_is_valid_comparison_operand::value, "invalid rhs operand in comparison"); - return { *static_cast(this), rhs{t} }; + return { *static_cast(this), rhs{t} }; } template - greater_equal_t> operator>=(T t) const + greater_equal_t> operator>=(T t) const { using rhs = wrap_operand_t; static_assert(_is_valid_comparison_operand::value, "invalid rhs operand in comparison"); - return { *static_cast(this), rhs{t} }; + return { *static_cast(this), rhs{t} }; } - is_null_t is_null() const + is_null_t is_null() const { - return { *static_cast(this) }; + return { *static_cast(this) }; } - is_null_t is_not_null() const + is_null_t is_not_null() const { - return { *static_cast(this) }; + return { *static_cast(this) }; } - sort_order_t asc() const + sort_order_t asc() const { - return { *static_cast(this) }; + return { *static_cast(this) }; } - sort_order_t desc() const + sort_order_t desc() const { - return { *static_cast(this) }; + return { *static_cast(this) }; } // Hint: use value_list wrapper for containers... template - in_t...> in(T... t) const + in_t...> in(T... t) const { static_assert(detail::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); - return { *static_cast(this), wrap_operand_t{t}... }; + return { *static_cast(this), wrap_operand_t{t}... }; } template - in_t...> not_in(T... t) const + in_t...> not_in(T... t) const { static_assert(detail::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); - return { *static_cast(this), wrap_operand_t{t}... }; + return { *static_cast(this), wrap_operand_t{t}... }; } }; - template + template struct alias_operators { template - expression_alias_t as(const alias_provider&) const + expression_alias_t as(const alias_provider&) const { - return { *static_cast(this) }; + return { *static_cast(this) }; } }; diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index 848f2acf..c96ea101 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -44,28 +44,34 @@ namespace sqlpp using _tag = ::sqlpp::tag::is_boolean; using _cpp_value_type = bool; - struct _parameter_t + template + using _is_valid_operand = is_boolean_t; + }; + + template<> + struct parameter_value_t { using _value_type = boolean; // FIXME + using _cpp_value_type = typename _value_type::_cpp_value_type; - _parameter_t(): + parameter_value_t(): _value(false), _is_null(true) {} - _parameter_t(const _cpp_value_type& value): + parameter_value_t(const _cpp_value_type& value): _value(value), _is_null(false) {} - _parameter_t& operator=(const _cpp_value_type& value) + parameter_value_t& operator=(const _cpp_value_type& value) { _value = value; _is_null = false; return *this; } - _parameter_t& operator=(const tvin_t>& t) + parameter_value_t& operator=(const tvin_t>& t) { if (t._is_trivial()) { @@ -80,7 +86,7 @@ namespace sqlpp return *this; } - _parameter_t& operator=(const std::nullptr_t&) + parameter_value_t& operator=(const std::nullptr_t&) { _value = false; _is_null = true; @@ -110,48 +116,41 @@ namespace sqlpp bool _is_null; }; + template + struct expression_operators: public basic_expression_operators + { template - struct _is_valid_operand + using _is_valid_operand = is_valid_operand; + + template + logical_and_t> operator and(T t) const { - static constexpr bool value = - is_expression_t::value // expressions are OK - and is_boolean_t::value // the correct value type is required, of course - ; - }; + using rhs = wrap_operand_t; + static_assert(_is_valid_operand::value, "invalid rhs operand"); - template - struct expression_operators: public basic_expression_operators - { - template - logical_and_t> operator and(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); - - return { *static_cast(this), rhs{t} }; - } - - template - logical_or_t> operator or(T t) const - { - using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand"); - - return { *static_cast(this), rhs{t} }; - } - - logical_not_t operator not() const - { - return { *static_cast(this) }; + return { *static_cast(this), rhs{t} }; } - }; - template - struct column_operators + template + logical_or_t> operator or(T t) const { - }; + using rhs = wrap_operand_t; + static_assert(_is_valid_operand::value, "invalid rhs operand"); + + return { *static_cast(this), rhs{t} }; + } + + logical_not_t operator not() const + { + return { *static_cast(this) }; + } }; + template + struct column_operators + { + }; + template struct result_field_t: public result_field_methods_t> { diff --git a/include/sqlpp11/boolean_expression.h b/include/sqlpp11/boolean_expression.h index 5463f94f..5c8716f3 100644 --- a/include/sqlpp11/boolean_expression.h +++ b/include/sqlpp11/boolean_expression.h @@ -33,7 +33,7 @@ namespace sqlpp { template - struct boolean_expression_t: public boolean::template expression_operators> + struct boolean_expression_t: public expression_operators, boolean> { using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 1ecbeb73..65700813 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -42,8 +42,9 @@ namespace sqlpp { template - struct column_t: public value_type_of::template expression_operators>, - public value_type_of::template column_operators> + struct column_t: + public expression_operators, value_type_of>, + public column_operators, value_type_of> { struct _traits { @@ -66,7 +67,7 @@ namespace sqlpp using _name_t = typename _spec_t::_name_t; template - using _is_valid_operand = typename value_type_of::template _is_valid_operand; + using _is_valid_operand = is_valid_operand, T>; column_t() = default; column_t(const column_t&) = default; diff --git a/include/sqlpp11/concat.h b/include/sqlpp11/concat.h index 5e337f7b..19d3a819 100644 --- a/include/sqlpp11/concat.h +++ b/include/sqlpp11/concat.h @@ -36,8 +36,9 @@ namespace sqlpp { // FIXME: Remove First, inherit from text_t template - struct concat_t: public value_type_of::template expression_operators>, - public alias_operators> + struct concat_t: + public expression_operators, value_type_of>, + public alias_operators> { using _traits = make_traits, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_named_expression>; using _recursive_traits = make_recursive_traits; diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index 814dcf22..78aa258f 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -33,8 +33,9 @@ namespace sqlpp { template - struct count_t: public sqlpp::integral::template expression_operators>, - public alias_operators> + struct count_t: + public expression_operators, integral>, + public alias_operators> { using _traits = make_traits<::sqlpp::integral, ::sqlpp::tag::is_expression, ::sqlpp::tag::is_named_expression>; using _recursive_traits = make_recursive_traits; diff --git a/include/sqlpp11/exists.h b/include/sqlpp11/exists.h index 867933cf..7a1cc982 100644 --- a/include/sqlpp11/exists.h +++ b/include/sqlpp11/exists.h @@ -32,8 +32,9 @@ namespace sqlpp { template - struct exists_t: public boolean::template expression_operators>, - public alias_operators> + struct exists_t: + public expression_operators, boolean>, + public alias_operators> { using _traits = make_traits; using _recursive_traits = make_recursive_traits