mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Merge branch 'feature/make_msvc_compile_again' into develop
This has actually led to cleaner code this time
This commit is contained in:
commit
e1ec4a8f53
@ -41,23 +41,28 @@
|
|||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_comparison_valid_rhs_operand_t, "invalid rhs operand in comparison");
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_comparison_rhs_is_expression_t, "rhs operand in comparison is not an expression");
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_comparison_lhs_rhs_differ_t, "identical lhs and rhs operand types in comparison");
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_comparison_rhs_is_valid_operand_t, "invalid rhs operand in comparison");
|
||||||
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_comparison_lhs_rhs_differ_t, "identical lhs and rhs operands in comparison");
|
||||||
|
|
||||||
template <typename LhsType, typename RhsType>
|
template <typename LhsType, typename RhsType>
|
||||||
using check_rhs_comparison_operand_t = static_combined_check_t<
|
using check_comparison_t = static_combined_check_t<
|
||||||
static_check_t<(is_expression_t<sqlpp::wrap_operand_t<RhsType>>::value // expressions are OK
|
static_check_t<logic::any_t<is_expression_t<sqlpp::wrap_operand_t<RhsType>>::value,
|
||||||
or
|
is_multi_expression_t<sqlpp::wrap_operand_t<RhsType>>::value>::value,
|
||||||
is_multi_expression_t<sqlpp::wrap_operand_t<RhsType>>::value) // multi-expressions like ANY are
|
assert_comparison_rhs_is_expression_t>,
|
||||||
// OK for comparisons, too
|
static_check_t<value_type_of<LhsType>::template _is_valid_operand<sqlpp::wrap_operand_t<RhsType>>::value,
|
||||||
and
|
assert_comparison_rhs_is_valid_operand_t>,
|
||||||
value_type_of<LhsType>::template _is_valid_operand<
|
|
||||||
sqlpp::wrap_operand_t<RhsType>>::value, // the correct value type is required, of course
|
|
||||||
assert_comparison_valid_rhs_operand_t>,
|
|
||||||
static_check_t<not std::is_same<LhsType, RhsType>::value, assert_comparison_lhs_rhs_differ_t>>;
|
static_check_t<not std::is_same<LhsType, RhsType>::value, assert_comparison_lhs_rhs_differ_t>>;
|
||||||
|
|
||||||
template <typename LhsType, typename... InTypes>
|
template <typename LhsType, typename... RhsType>
|
||||||
using check_rhs_in_arguments_t = static_combined_check_t<check_rhs_comparison_operand_t<LhsType, InTypes>...>;
|
using check_in_t = static_combined_check_t<
|
||||||
|
static_check_t<logic::all_t<is_expression_t<sqlpp::wrap_operand_t<RhsType>>::value...>::value,
|
||||||
|
assert_comparison_rhs_is_expression_t>,
|
||||||
|
static_check_t<logic::all_t<value_type_of<LhsType>::template _is_valid_operand<
|
||||||
|
sqlpp::wrap_operand_t<RhsType>>::value...>::value,
|
||||||
|
assert_comparison_rhs_is_valid_operand_t>,
|
||||||
|
static_check_t<logic::none_t<std::is_same<LhsType, RhsType>::value...>::value,
|
||||||
|
assert_comparison_lhs_rhs_differ_t>>;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@ -100,10 +105,8 @@ namespace sqlpp
|
|||||||
template <template <typename Lhs, typename Rhs> class NewExpr, typename T>
|
template <template <typename Lhs, typename Rhs> class NewExpr, typename T>
|
||||||
struct _new_binary_expression
|
struct _new_binary_expression
|
||||||
{
|
{
|
||||||
using type = new_binary_expression_t<check_rhs_comparison_operand_t<Expr, wrap_operand_t<T>>,
|
using type =
|
||||||
NewExpr,
|
new_binary_expression_t<check_comparison_t<Expr, wrap_operand_t<T>>, NewExpr, Expr, wrap_operand_t<T>>;
|
||||||
Expr,
|
|
||||||
wrap_operand_t<T>>;
|
|
||||||
};
|
};
|
||||||
template <template <typename Lhs, typename Rhs> class NewExpr, typename T>
|
template <template <typename Lhs, typename Rhs> class NewExpr, typename T>
|
||||||
using _new_binary_expression_t = typename _new_binary_expression<NewExpr, T>::type;
|
using _new_binary_expression_t = typename _new_binary_expression<NewExpr, T>::type;
|
||||||
@ -111,7 +114,7 @@ namespace sqlpp
|
|||||||
// workaround for msvs bug
|
// workaround for msvs bug
|
||||||
// template <template <typename Lhs, typename... Rhs> class NewExpr, typename... T>
|
// template <template <typename Lhs, typename... Rhs> class NewExpr, typename... T>
|
||||||
// using _new_nary_expression_t =
|
// using _new_nary_expression_t =
|
||||||
// new_nary_expression_t<logic::all_t<check_rhs_comparison_operand_t<
|
// new_nary_expression_t<logic::all_t<check_comparison_t<
|
||||||
// wrap_operand_t<T>>::value...>,
|
// wrap_operand_t<T>>::value...>,
|
||||||
// NewExpr,
|
// NewExpr,
|
||||||
// Expr,
|
// Expr,
|
||||||
@ -119,18 +122,17 @@ namespace sqlpp
|
|||||||
template <template <typename Lhs, typename... Rhs> class NewExpr, typename... T>
|
template <template <typename Lhs, typename... Rhs> class NewExpr, typename... T>
|
||||||
struct _new_nary_expression
|
struct _new_nary_expression
|
||||||
{
|
{
|
||||||
using type =
|
using type = new_nary_expression_t<logic::all_t<check_comparison_t<Expr, wrap_operand_t<T>>::value...>,
|
||||||
new_nary_expression_t<logic::all_t<check_rhs_comparison_operand_t<Expr, wrap_operand_t<T>>::value...>,
|
NewExpr,
|
||||||
NewExpr,
|
Expr,
|
||||||
Expr,
|
wrap_operand_t<T>...>;
|
||||||
wrap_operand_t<T>...>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
_new_binary_expression_t<equal_to_t, T> operator==(T t) const
|
_new_binary_expression_t<equal_to_t, T> operator==(T t) const
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_rhs_comparison_operand_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>::_();
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -139,7 +141,7 @@ namespace sqlpp
|
|||||||
_new_binary_expression_t<not_equal_to_t, T> operator!=(T t) const
|
_new_binary_expression_t<not_equal_to_t, T> operator!=(T t) const
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_rhs_comparison_operand_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>::_();
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -148,7 +150,7 @@ namespace sqlpp
|
|||||||
_new_binary_expression_t<less_than_t, T> operator<(T t) const
|
_new_binary_expression_t<less_than_t, T> operator<(T t) const
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_rhs_comparison_operand_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>::_();
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -157,7 +159,7 @@ namespace sqlpp
|
|||||||
_new_binary_expression_t<less_equal_t, T> operator<=(T t) const
|
_new_binary_expression_t<less_equal_t, T> operator<=(T t) const
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_rhs_comparison_operand_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>::_();
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -166,7 +168,7 @@ namespace sqlpp
|
|||||||
_new_binary_expression_t<greater_than_t, T> operator>(T t) const
|
_new_binary_expression_t<greater_than_t, T> operator>(T t) const
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_rhs_comparison_operand_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>::_();
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -175,7 +177,7 @@ namespace sqlpp
|
|||||||
_new_binary_expression_t<greater_equal_t, T> operator>=(T t) const
|
_new_binary_expression_t<greater_equal_t, T> operator>=(T t) const
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_rhs_comparison_operand_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>::_();
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -211,7 +213,7 @@ namespace sqlpp
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
typename _new_nary_expression<in_t, T...>::type in(T... t) const
|
typename _new_nary_expression<in_t, T...>::type in(T... t) const
|
||||||
{
|
{
|
||||||
static_combined_check_t<check_rhs_comparison_operand_t<Expr, T>...>::_();
|
check_in_t<Expr, T...>::_();
|
||||||
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +227,7 @@ namespace sqlpp
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
typename _new_nary_expression<not_in_t, T...>::type not_in(T... t) const
|
typename _new_nary_expression<not_in_t, T...>::type not_in(T... t) const
|
||||||
{
|
{
|
||||||
static_combined_check_t<check_rhs_comparison_operand_t<Expr, T>...>::_();
|
check_in_t<Expr, T...>::_();
|
||||||
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace
|
|||||||
template <typename Assert, typename Operand>
|
template <typename Assert, typename Operand>
|
||||||
void static_check_comparison(const Operand& operand)
|
void static_check_comparison(const Operand& operand)
|
||||||
{
|
{
|
||||||
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someDayPoint), Operand>;
|
using CheckResult = sqlpp::check_comparison_t<decltype(t.someDayPoint), Operand>;
|
||||||
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
||||||
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
||||||
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
||||||
@ -73,14 +73,14 @@ namespace
|
|||||||
|
|
||||||
void disallowed_comparands()
|
void disallowed_comparands()
|
||||||
{
|
{
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(17);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(17);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>('a');
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>('a');
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(std::string("a"));
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(std::string("a"));
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_expression_t>(t);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someBool);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someBool);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someFloat);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someFloat);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someInt);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someInt);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someString);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace
|
|||||||
template <typename Assert, typename Operand>
|
template <typename Assert, typename Operand>
|
||||||
void static_check_comparison(const Operand& operand)
|
void static_check_comparison(const Operand& operand)
|
||||||
{
|
{
|
||||||
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someTimePoint), Operand>;
|
using CheckResult = sqlpp::check_comparison_t<decltype(t.someTimePoint), Operand>;
|
||||||
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
||||||
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
||||||
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
||||||
@ -73,14 +73,14 @@ namespace
|
|||||||
|
|
||||||
void disallowed_comparands()
|
void disallowed_comparands()
|
||||||
{
|
{
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(17);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(17);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>('a');
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>('a');
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(std::string("a"));
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(std::string("a"));
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_expression_t>(t);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someBool);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someBool);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someFloat);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someFloat);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someInt);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someInt);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someString);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace
|
|||||||
template <typename Assert, typename Operand>
|
template <typename Assert, typename Operand>
|
||||||
void static_check_self_compare(const Operand& operand)
|
void static_check_self_compare(const Operand& operand)
|
||||||
{
|
{
|
||||||
using CheckResult = sqlpp::check_rhs_comparison_operand_t<Operand, Operand>;
|
using CheckResult = sqlpp::check_comparison_t<Operand, Operand>;
|
||||||
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
||||||
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
||||||
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
||||||
|
@ -46,7 +46,7 @@ namespace
|
|||||||
template <typename Assert, typename Operand>
|
template <typename Assert, typename Operand>
|
||||||
void static_check_comparison(const Operand& operand)
|
void static_check_comparison(const Operand& operand)
|
||||||
{
|
{
|
||||||
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someString), Operand>;
|
using CheckResult = sqlpp::check_comparison_t<decltype(t.someString), Operand>;
|
||||||
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
||||||
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
||||||
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
||||||
@ -73,14 +73,14 @@ namespace
|
|||||||
|
|
||||||
void disallowed_comparands()
|
void disallowed_comparands()
|
||||||
{
|
{
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(17);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(17);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(17.4);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(17.4);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_expression_t>(t);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someBool);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someBool);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someFloat);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someFloat);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someInt);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someInt);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someDayPoint);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someDayPoint);
|
||||||
static_check_comparison<sqlpp::assert_comparison_valid_rhs_operand_t>(t.someTimePoint);
|
static_check_comparison<sqlpp::assert_comparison_rhs_is_valid_operand_t>(t.someTimePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Expected, typename Expression>
|
template <typename Expected, typename Expression>
|
||||||
|
Loading…
Reference in New Issue
Block a user