0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Migrated remove and update to using arg_selector

This commit is contained in:
rbock 2014-03-27 08:37:05 +01:00
parent 1a39d31b3e
commit 1a347048df
3 changed files with 15 additions and 39 deletions

View File

@ -34,6 +34,8 @@ namespace sqlpp
template<typename Target>
struct arg_selector
{
static Target _(Target, Target t) { return t; }
template<typename X>
static Target _(X, Target t) { return t; }

View File

@ -35,6 +35,7 @@
#include <sqlpp11/vendor/using.h>
#include <sqlpp11/vendor/where.h>
#include <sqlpp11/vendor/policy_update.h>
#include <sqlpp11/detail/arg_selector.h>
namespace sqlpp
{
@ -75,25 +76,11 @@ namespace sqlpp
remove_t()
{}
template<typename X>
remove_t(X x, Table table):
_table(table),
_using(x._using),
_where(x._where)
{}
template<typename X>
remove_t(X x, Using using_):
_table(x._table),
_using(using_),
_where(x._where)
{}
template<typename X>
remove_t(X x, Where where):
_table(x._table),
_using(x._using),
_where(where)
template<typename Statement, typename T>
remove_t(Statement s, T t):
_table(detail::arg_selector<Table>::_(s._table, t)),
_using(detail::arg_selector<Using>::_(s._using, t)),
_where(detail::arg_selector<Where>::_(s._where, t))
{}
remove_t(const remove_t&) = default;

View File

@ -35,6 +35,7 @@
#include <sqlpp11/vendor/noop.h>
#include <sqlpp11/vendor/where.h>
#include <sqlpp11/vendor/policy_update.h>
#include <sqlpp11/detail/arg_selector.h>
namespace sqlpp
{
@ -75,29 +76,15 @@ namespace sqlpp
using _parameter_tuple_t = std::tuple<Table, UpdateList, Where>;
using _parameter_list_t = typename make_parameter_list_t<update_t>::type;
// Constructors
update_t()
{}
// Constructors
template<typename X>
update_t(X x, Table table):
_table(table),
_update_list(x._update_list),
_where(x._where)
{}
template<typename X>
update_t(X x, UpdateList update_list):
_table(x._table),
_update_list(update_list),
_where(x._where)
{}
template<typename X>
update_t(X x, Where where):
_table(x._table),
_update_list(x._update_list),
_where(where)
template<typename Statement, typename T>
update_t(Statement s, T t):
_table(detail::arg_selector<Table>::_(s._table, t)),
_update_list(detail::arg_selector<UpdateList>::_(s._update_list, t)),
_where(detail::arg_selector<Where>::_(s._where, t))
{}
update_t(const update_t&) = default;