0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Added bitwise_and and bitwise_or to integral

This commit is contained in:
rbock 2014-08-12 21:58:44 +02:00
parent ad1c5f94bb
commit b52591df58
2 changed files with 54 additions and 0 deletions

View File

@ -132,6 +132,21 @@ namespace sqlpp
using _traits = make_traits<ValueType>; using _traits = make_traits<ValueType>;
static constexpr const char* _name = "+"; static constexpr const char* _name = "+";
}; };
template<typename ValueType>
struct bitwise_and
{
using _traits = make_traits<ValueType>;
static constexpr const char* _name = "&";
};
template<typename ValueType>
struct bitwise_or
{
using _traits = make_traits<ValueType>;
static constexpr const char* _name = "|";
};
} }
template<typename Lhs, typename O, typename Rhs> template<typename Lhs, typename O, typename Rhs>
@ -188,6 +203,11 @@ namespace sqlpp
template<typename ValueType, typename Rhs> template<typename ValueType, typename Rhs>
using unary_minus_t = unary_expression_t<op::unary_minus<ValueType>, Rhs>; using unary_minus_t = unary_expression_t<op::unary_minus<ValueType>, Rhs>;
template<typename Lhs, typename ValueType, typename Rhs>
using bitwise_and_t = binary_expression_t<Lhs, op::bitwise_and<ValueType>, Rhs>;
template<typename Lhs, typename ValueType, typename Rhs>
using bitwise_or_t = binary_expression_t<Lhs, op::bitwise_or<ValueType>, Rhs>;
} }
#endif #endif

View File

@ -65,6 +65,21 @@ namespace sqlpp
return *this; return *this;
} }
_parameter_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
{
if (t._is_trivial())
{
_value = 0;
_is_null = true;
}
else
{
_value = t._value._t;
_is_null = false;
}
return *this;
}
void set_null() void set_null()
{ {
_value = 0; _value = 0;
@ -160,6 +175,25 @@ namespace sqlpp
{ {
return { *static_cast<const Base*>(this) }; return { *static_cast<const Base*>(this) };
} }
template<typename T>
bitwise_and_t<Base, value_type_t<T>, wrap_operand_t<T>> operator &(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
return { *static_cast<const Base*>(this), {t} };
}
template<typename T>
bitwise_or_t<Base, value_type_t<T>, wrap_operand_t<T>> operator |(T t) const
{
using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand");
return { *static_cast<const Base*>(this), {t} };
}
}; };
template<typename Base> template<typename Base>