mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-03 03:30:35 -06:00
fixed some expressions, added tests
This commit is contained in:
@@ -43,33 +43,61 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_not_unsigned_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = plus_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = integral;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_not_unsigned_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = minus_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = integral;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_not_unsigned_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = multiplies_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_divides<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_t>>
|
||||
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = integral;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_divides<L, R, binary_operand_check_t<L, is_integral_t, R, is_numeric_not_unsigned_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_divides<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = integral;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_modulus<L, R, binary_operand_check_t<L, is_integral_t, R, is_integral_t>>
|
||||
{
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct integral;
|
||||
|
||||
template <typename Expression>
|
||||
struct expression_operators<Expression, unsigned_integral> : public basic_expression_operators<Expression>
|
||||
{
|
||||
@@ -46,28 +48,35 @@ namespace sqlpp
|
||||
struct return_type_plus<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = plus_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
using type = value_type_of<wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_numeric_t>>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_numeric_not_unsigned_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = minus_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
using type = value_type_of<wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_minus<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = minus_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = multiplies_t<wrap_operand_t<L>, value_type_of<wrap_operand_t<R>>, wrap_operand_t<R>>;
|
||||
using type = value_type_of<wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct return_type_divides<L, R, binary_operand_check_t<L, is_unsigned_integral_t, R, is_numeric_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||
using type = value_type_of<wrap_operand_t<R>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
@@ -88,7 +97,7 @@ namespace sqlpp
|
||||
struct return_type_unary_minus<T, Defer, unary_operand_check_t<T, is_unsigned_integral_t>>
|
||||
{
|
||||
using check = consistent_t;
|
||||
using type = unary_minus_t<unsigned_integral, wrap_operand_t<T>>;
|
||||
using type = unary_minus_t<integral, wrap_operand_t<T>>;
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
|
||||
@@ -95,6 +95,9 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
using is_numeric_t = logic::any_t<is_integral_t<T>::value, is_unsigned_integral_t<T>::value, is_floating_point_t<T>::value>;
|
||||
|
||||
template <typename T>
|
||||
using is_numeric_not_unsigned_t = logic::any_t<is_integral_t<T>::value, not is_unsigned_integral_t<T>::value, is_floating_point_t<T>::value>;
|
||||
|
||||
template <typename T>
|
||||
using is_day_or_time_point_t = logic::any_t<is_day_point_t<T>::value, is_time_point_t<T>::value>;
|
||||
|
||||
|
||||
@@ -137,6 +137,29 @@ int SelectType(int, char* [])
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
//subtraction on unsigned makes it signed
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_minus_t<T,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_unary_minus_t<T,T>>::value, "type requirement");
|
||||
//any operation on float makes it float
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_minus_t<T,sqlpp::floating_point>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_plus_t<T,sqlpp::floating_point>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_multiplies_t<T,sqlpp::floating_point>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_divides_t<T,sqlpp::floating_point>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_minus_t<sqlpp::floating_point,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_plus_t<sqlpp::floating_point,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_multiplies_t<sqlpp::floating_point,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_divides_t<sqlpp::floating_point,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_modulus_t<sqlpp::floating_point,T>>::value, "type requirement");
|
||||
//signed operation on unsigned makes it signed
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_minus_t<T,sqlpp::integral>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_plus_t<T,sqlpp::integral>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_multiplies_t<T,sqlpp::integral>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_divides_t<T,sqlpp::integral>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_minus_t<sqlpp::integral,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_plus_t<sqlpp::integral,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_multiplies_t<sqlpp::integral,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_divides_t<sqlpp::integral,T>>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<sqlpp::return_type_modulus_t<sqlpp::integral,T>>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a floating point table column
|
||||
|
||||
Reference in New Issue
Block a user