mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Added some template aliases to ease specialization and added a few more operator overloads
This commit is contained in:
parent
63ac89accb
commit
31127812a0
@ -41,34 +41,6 @@ namespace sqlpp
|
|||||||
struct boolean;
|
struct boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace vendor
|
|
||||||
{
|
|
||||||
// operators
|
|
||||||
struct lt_
|
|
||||||
{
|
|
||||||
using _value_type = detail::boolean;
|
|
||||||
static constexpr const char* _name = "<";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct le_
|
|
||||||
{
|
|
||||||
using _value_type = detail::boolean;
|
|
||||||
static constexpr const char* _name = "<=";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ge_
|
|
||||||
{
|
|
||||||
using _value_type = detail::boolean;
|
|
||||||
static constexpr const char* _name = ">=";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gt_
|
|
||||||
{
|
|
||||||
using _value_type = detail::boolean;
|
|
||||||
static constexpr const char* _name = ">";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// basic operators
|
// basic operators
|
||||||
template<typename Base, template<typename> class Constraint>
|
template<typename Base, template<typename> class Constraint>
|
||||||
struct basic_operators
|
struct basic_operators
|
||||||
@ -87,28 +59,28 @@ namespace sqlpp
|
|||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, vendor::lt_, typename Constraint<T>::type> operator<(T&& t) const
|
vendor::less_than_t<Base, typename Constraint<T>::type> operator<(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, vendor::le_, typename Constraint<T>::type> operator<=(T&& t) const
|
vendor::less_equal_t<Base, typename Constraint<T>::type> operator<=(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, vendor::ge_, typename Constraint<T>::type> operator>=(T&& t) const
|
vendor::greater_than_t<Base, typename Constraint<T>::type> operator>(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, vendor::gt_, typename Constraint<T>::type> operator>(T&& t) const
|
vendor::greater_equal_t<Base, typename Constraint<T>::type> operator>=(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
|
@ -38,18 +38,6 @@ namespace sqlpp
|
|||||||
// boolean operators
|
// boolean operators
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
struct or_
|
|
||||||
{
|
|
||||||
using _value_type = boolean;
|
|
||||||
static constexpr const char* _name = " OR ";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct and_
|
|
||||||
{
|
|
||||||
using _value_type = boolean;
|
|
||||||
static constexpr const char* _name = " AND ";
|
|
||||||
};
|
|
||||||
|
|
||||||
// boolean value type
|
// boolean value type
|
||||||
struct boolean
|
struct boolean
|
||||||
{
|
{
|
||||||
@ -178,20 +166,20 @@ namespace sqlpp
|
|||||||
struct operators: public basic_operators<Base, _constraint>
|
struct operators: public basic_operators<Base, _constraint>
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, and_, typename _constraint<T>::type> operator and(T&& t) const
|
vendor::logical_and_t<Base, typename _constraint<T>::type> operator and(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, or_, typename _constraint<T>::type> operator or(T&& t) const
|
vendor::logical_or_t<Base, typename _constraint<T>::type> operator or(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
vendor::not_t<Base> operator not() const
|
vendor::logical_not_t<Base> operator not() const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be as operand for operator not");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be as operand for operator not");
|
||||||
return { *static_cast<const Base*>(this) };
|
return { *static_cast<const Base*>(this) };
|
||||||
|
@ -161,30 +161,6 @@ namespace sqlpp
|
|||||||
_cpp_value_type _value;
|
_cpp_value_type _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct plus_
|
|
||||||
{
|
|
||||||
using _value_type = floating_point;
|
|
||||||
static constexpr const char* _name = "+";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct minus_
|
|
||||||
{
|
|
||||||
using _value_type = floating_point;
|
|
||||||
static constexpr const char* _name = "-";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct multiplies_
|
|
||||||
{
|
|
||||||
using _value_type = floating_point;
|
|
||||||
static constexpr const char* _name = "*";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct divides_
|
|
||||||
{
|
|
||||||
using _value_type = floating_point;
|
|
||||||
static constexpr const char* _name = "/";
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using _constraint = operand_t<T, is_numeric_t>;
|
using _constraint = operand_t<T, is_numeric_t>;
|
||||||
|
|
||||||
@ -192,33 +168,45 @@ namespace sqlpp
|
|||||||
struct operators: public basic_operators<Base, _constraint>
|
struct operators: public basic_operators<Base, _constraint>
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, plus_, typename _constraint<T>::type> operator +(T&& t) const
|
vendor::plus_t<Base, floating_point, typename _constraint<T>::type> operator +(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, minus_, typename _constraint<T>::type> operator -(T&& t) const
|
vendor::minus_t<Base, floating_point, typename _constraint<T>::type> operator -(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, multiplies_, typename _constraint<T>::type> operator *(T&& t) const
|
vendor::multiplies_t<Base, floating_point, typename _constraint<T>::type> operator *(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, divides_, typename _constraint<T>::type> operator /(T&& t) const
|
vendor::divides_t<Base, typename _constraint<T>::type> operator /(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vendor::unary_plus_t<floating_point, Base> operator +() const
|
||||||
|
{
|
||||||
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as unary operand");
|
||||||
|
return { *static_cast<const Base*>(this) };
|
||||||
|
}
|
||||||
|
|
||||||
|
vendor::unary_minus_t<floating_point, Base> operator -() const
|
||||||
|
{
|
||||||
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as unary operand");
|
||||||
|
return { *static_cast<const Base*>(this) };
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
auto operator +=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() + std::forward<T>(t))
|
auto operator +=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() + std::forward<T>(t))
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <sqlpp11/basic_operators.h>
|
#include <sqlpp11/basic_operators.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/exception.h>
|
#include <sqlpp11/exception.h>
|
||||||
|
#include <sqlpp11/vendor/value_type.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
@ -160,33 +161,6 @@ namespace sqlpp
|
|||||||
_cpp_value_type _value;
|
_cpp_value_type _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct plus_
|
|
||||||
{
|
|
||||||
using _value_type = typename vendor::wrap_operand<typename std::decay<T>::type>::type::_value_type;
|
|
||||||
static constexpr const char* _name = "+";
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct minus_
|
|
||||||
{
|
|
||||||
using _value_type = typename vendor::wrap_operand<typename std::decay<T>::type>::type::_value_type;
|
|
||||||
static constexpr const char* _name = "-";
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct multiplies_
|
|
||||||
{
|
|
||||||
using _value_type = typename vendor::wrap_operand<typename std::decay<T>::type>::type::_value_type;
|
|
||||||
static constexpr const char* _name = "*";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct divides_
|
|
||||||
{
|
|
||||||
using _value_type = floating_point;
|
|
||||||
static constexpr const char* _name = "/";
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using _constraint = operand_t<T, is_numeric_t>;
|
using _constraint = operand_t<T, is_numeric_t>;
|
||||||
|
|
||||||
@ -194,33 +168,52 @@ namespace sqlpp
|
|||||||
struct operators: public basic_operators<Base, _constraint>
|
struct operators: public basic_operators<Base, _constraint>
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, plus_<T>, typename _constraint<T>::type> operator +(T&& t) const
|
vendor::plus_t<Base, vendor::value_type_t<T>, typename _constraint<T>::type> operator +(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, minus_<T>, typename _constraint<T>::type> operator -(T&& t) const
|
vendor::minus_t<Base, vendor::value_type_t<T>, typename _constraint<T>::type> operator -(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, multiplies_<T>, typename _constraint<T>::type> operator *(T&& t) const
|
vendor::multiplies_t<Base, vendor::value_type_t<T>, typename _constraint<T>::type> operator *(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
vendor::binary_expression_t<Base, divides_, typename _constraint<T>::type> operator /(T&& t) const
|
vendor::divides_t<Base, typename _constraint<T>::type> operator /(T&& t) const
|
||||||
{
|
{
|
||||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
vendor::modulus_t<Base, typename _constraint<T>::type> operator %(T&& t) const
|
||||||
|
{
|
||||||
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||||
|
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||||
|
}
|
||||||
|
|
||||||
|
vendor::unary_plus_t<integral, Base> operator +() const
|
||||||
|
{
|
||||||
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as unary operand");
|
||||||
|
return { *static_cast<const Base*>(this) };
|
||||||
|
}
|
||||||
|
|
||||||
|
vendor::unary_minus_t<integral, Base> operator -() const
|
||||||
|
{
|
||||||
|
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as unary operand");
|
||||||
|
return { *static_cast<const Base*>(this) };
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
auto operator +=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() + std::forward<T>(t))
|
auto operator +=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() + std::forward<T>(t))
|
||||||
{
|
{
|
||||||
|
52
include/sqlpp11/vendor/expression.h
vendored
52
include/sqlpp11/vendor/expression.h
vendored
@ -173,28 +173,28 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename Lhs>
|
template<typename Lhs>
|
||||||
struct not_t: public detail::boolean::template operators<not_t<Lhs>>
|
struct logical_not_t: public detail::boolean::template operators<logical_not_t<Lhs>>
|
||||||
{
|
{
|
||||||
using _value_type = detail::boolean;
|
using _value_type = detail::boolean;
|
||||||
using _parameter_tuple_t = std::tuple<Lhs>;
|
using _parameter_tuple_t = std::tuple<Lhs>;
|
||||||
|
|
||||||
not_t(Lhs l):
|
logical_not_t(Lhs l):
|
||||||
_lhs(l)
|
_lhs(l)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
not_t(const not_t&) = default;
|
logical_not_t(const logical_not_t&) = default;
|
||||||
not_t(not_t&&) = default;
|
logical_not_t(logical_not_t&&) = default;
|
||||||
not_t& operator=(const not_t&) = default;
|
logical_not_t& operator=(const logical_not_t&) = default;
|
||||||
not_t& operator=(not_t&&) = default;
|
logical_not_t& operator=(logical_not_t&&) = default;
|
||||||
~not_t() = default;
|
~logical_not_t() = default;
|
||||||
|
|
||||||
Lhs _lhs;
|
Lhs _lhs;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Context, typename Lhs>
|
template<typename Context, typename Lhs>
|
||||||
struct interpreter_t<Context, not_t<Lhs>>
|
struct interpreter_t<Context, logical_not_t<Lhs>>
|
||||||
{
|
{
|
||||||
using T = not_t<Lhs>;
|
using T = logical_not_t<Lhs>;
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
static Context& _(const T& t, Context& context)
|
||||||
{
|
{
|
||||||
@ -242,6 +242,40 @@ namespace sqlpp
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename O, typename Rhs>
|
||||||
|
struct unary_expression_t: public O::_value_type::template operators<unary_expression_t<O, Rhs>>
|
||||||
|
{
|
||||||
|
using _value_type = typename O::_value_type;
|
||||||
|
using _parameter_tuple_t = std::tuple<Rhs>;
|
||||||
|
|
||||||
|
unary_expression_t(Rhs rhs):
|
||||||
|
_rhs(rhs)
|
||||||
|
{}
|
||||||
|
|
||||||
|
unary_expression_t(const unary_expression_t&) = default;
|
||||||
|
unary_expression_t(unary_expression_t&&) = default;
|
||||||
|
unary_expression_t& operator=(const unary_expression_t&) = default;
|
||||||
|
unary_expression_t& operator=(unary_expression_t&&) = default;
|
||||||
|
~unary_expression_t() = default;
|
||||||
|
|
||||||
|
Rhs _rhs;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Context, typename O, typename Rhs>
|
||||||
|
struct interpreter_t<Context, unary_expression_t<O, Rhs>>
|
||||||
|
{
|
||||||
|
using T = unary_expression_t<O, Rhs>;
|
||||||
|
|
||||||
|
static Context& _(const T& t, Context& context)
|
||||||
|
{
|
||||||
|
context << "(";
|
||||||
|
context << O::_name;
|
||||||
|
interpret(t._rhs, context);
|
||||||
|
context << ")";
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
131
include/sqlpp11/vendor/expression_fwd.h
vendored
131
include/sqlpp11/vendor/expression_fwd.h
vendored
@ -41,10 +41,139 @@ namespace sqlpp
|
|||||||
struct not_equal_t;
|
struct not_equal_t;
|
||||||
|
|
||||||
template<typename Lhs>
|
template<typename Lhs>
|
||||||
struct not_t;
|
struct logical_not_t;
|
||||||
|
|
||||||
|
namespace tag
|
||||||
|
{
|
||||||
|
struct less_than
|
||||||
|
{
|
||||||
|
using _value_type = detail::boolean;
|
||||||
|
static constexpr const char* _name = "<";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct less_equal
|
||||||
|
{
|
||||||
|
using _value_type = detail::boolean;
|
||||||
|
static constexpr const char* _name = "<=";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct greater_equal
|
||||||
|
{
|
||||||
|
using _value_type = detail::boolean;
|
||||||
|
static constexpr const char* _name = ">=";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct greater_than
|
||||||
|
{
|
||||||
|
using _value_type = detail::boolean;
|
||||||
|
static constexpr const char* _name = ">";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct logical_or
|
||||||
|
{
|
||||||
|
using _value_type = detail::boolean;
|
||||||
|
static constexpr const char* _name = " OR ";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct logical_and
|
||||||
|
{
|
||||||
|
using _value_type = detail::boolean;
|
||||||
|
static constexpr const char* _name = " AND ";
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ValueType>
|
||||||
|
struct plus
|
||||||
|
{
|
||||||
|
using _value_type = ValueType;
|
||||||
|
static constexpr const char* _name = "+";
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ValueType>
|
||||||
|
struct minus
|
||||||
|
{
|
||||||
|
using _value_type = ValueType;
|
||||||
|
static constexpr const char* _name = "-";
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ValueType>
|
||||||
|
struct multiplies
|
||||||
|
{
|
||||||
|
using _value_type = ValueType;
|
||||||
|
static constexpr const char* _name = "*";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct divides
|
||||||
|
{
|
||||||
|
using _value_type = detail::floating_point;
|
||||||
|
static constexpr const char* _name = "/";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct modulus
|
||||||
|
{
|
||||||
|
using _value_type = detail::integral;
|
||||||
|
static constexpr const char* _name = "%";
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ValueType>
|
||||||
|
struct unary_minus
|
||||||
|
{
|
||||||
|
using _value_type = ValueType;
|
||||||
|
static constexpr const char* _name = "-";
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ValueType>
|
||||||
|
struct unary_plus
|
||||||
|
{
|
||||||
|
using _value_type = ValueType;
|
||||||
|
static constexpr const char* _name = "+";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Lhs, typename O, typename Rhs>
|
template<typename Lhs, typename O, typename Rhs>
|
||||||
struct binary_expression_t;
|
struct binary_expression_t;
|
||||||
|
|
||||||
|
template<typename O, typename Rhs>
|
||||||
|
struct unary_expression_t;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using less_than_t = binary_expression_t<Lhs, tag::less_than, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using less_equal_t = binary_expression_t<Lhs, tag::less_equal, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using greater_than_t = binary_expression_t<Lhs, tag::greater_than, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using greater_equal_t = binary_expression_t<Lhs, tag::greater_equal, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using logical_and_t = binary_expression_t<Lhs, tag::logical_and, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using logical_or_t = binary_expression_t<Lhs, tag::logical_or, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename ValueType, typename Rhs>
|
||||||
|
using plus_t = binary_expression_t<Lhs, tag::plus<ValueType>, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename ValueType, typename Rhs>
|
||||||
|
using minus_t = binary_expression_t<Lhs, tag::minus<ValueType>, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename ValueType, typename Rhs>
|
||||||
|
using multiplies_t = binary_expression_t<Lhs, tag::multiplies<ValueType>, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using divides_t = binary_expression_t<Lhs, tag::divides, Rhs>;
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
using modulus_t = binary_expression_t<Lhs, tag::modulus, Rhs>;
|
||||||
|
|
||||||
|
template<typename ValueType, typename Rhs>
|
||||||
|
using unary_plus_t = unary_expression_t<tag::unary_plus<ValueType>, Rhs>;
|
||||||
|
|
||||||
|
template<typename ValueType, typename Rhs>
|
||||||
|
using unary_minus_t = unary_expression_t<tag::unary_minus<ValueType>, Rhs>;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
41
include/sqlpp11/vendor/value_type.h
vendored
Normal file
41
include/sqlpp11/vendor/value_type.h
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Roland Bock
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SQLPP_VALUE_TYPE_H
|
||||||
|
#define SQLPP_VALUE_TYPE_H
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
#include <sqlpp11/vendor/wrap_operand.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
namespace vendor
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
using value_type_t = typename wrap_operand<typename std::decay<T>::type>::type::_value_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -43,6 +43,9 @@ int main()
|
|||||||
TabSample t;
|
TabSample t;
|
||||||
|
|
||||||
interpret(t.alpha, printer).flush();
|
interpret(t.alpha, printer).flush();
|
||||||
|
interpret(-t.alpha, printer).flush();
|
||||||
|
interpret(+t.alpha, printer).flush();
|
||||||
|
interpret(-(t.alpha + 7), printer).flush();
|
||||||
interpret(t.alpha = 0, printer).flush();
|
interpret(t.alpha = 0, printer).flush();
|
||||||
interpret(t.alpha = sqlpp::tvin(0), printer).flush();
|
interpret(t.alpha = sqlpp::tvin(0), printer).flush();
|
||||||
interpret(t.alpha == 0, printer).flush();
|
interpret(t.alpha == 0, printer).flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user