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

Made parameter_list's bind non-recursive

This commit is contained in:
rbock 2014-05-07 18:51:18 +02:00
parent b9133cf3a1
commit d831f98c9a
2 changed files with 8 additions and 15 deletions

View File

@ -27,8 +27,9 @@
#ifndef SQLPP_PARAMETER_LIST_H
#define SQLPP_PARAMETER_LIST_H
#include <sqlpp11/vendor/wrong.h>
#include <tuple>
#include <sqlpp11/vendor/wrong.h>
#include <sqlpp11/detail/index_sequence.h>
namespace sqlpp
{
@ -50,23 +51,15 @@ namespace sqlpp
template<typename Target>
void _bind(Target& target) const
{
_bind_impl(target, index_t<0>());
_bind_impl(target, ::sqlpp::detail::make_index_sequence<size::value>{});
}
private:
template<size_t> struct index_t {}; // this is just for overloading
template<typename Target, size_t index>
void _bind_impl(Target& target, const index_t<index>&) const
{
const auto& parameter = static_cast<typename std::tuple_element<index, const _member_tuple_t>::type&>(*this)();
parameter._bind(target, index);
_bind_impl(target, index_t<index + 1>());
}
template<typename Target>
void _bind_impl(Target& target, const index_t<size::value>&) const
template<typename Target, size_t... Is>
void _bind_impl(Target& target, const ::sqlpp::detail::index_sequence<Is...>&) const
{
using swallow = int[]; // see interpret_tuple.h
(void) swallow{(static_cast<typename std::tuple_element<Is, const _member_tuple_t>::type&>(*this)()._bind(target, Is), 0)...};
}
};

View File

@ -55,7 +55,7 @@ namespace sqlpp
// See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777"
// Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could be used
using swallow = int[];
(void) swallow{(interpret_tuple_element(std::get<Is>(t), separator, context, Is) ,0)...};
(void) swallow{(interpret_tuple_element(std::get<Is>(t), separator, context, Is), 0)...};
return context;
}