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 #ifndef SQLPP_PARAMETER_LIST_H
#define SQLPP_PARAMETER_LIST_H #define SQLPP_PARAMETER_LIST_H
#include <sqlpp11/vendor/wrong.h>
#include <tuple> #include <tuple>
#include <sqlpp11/vendor/wrong.h>
#include <sqlpp11/detail/index_sequence.h>
namespace sqlpp namespace sqlpp
{ {
@ -50,23 +51,15 @@ namespace sqlpp
template<typename Target> template<typename Target>
void _bind(Target& target) const void _bind(Target& target) const
{ {
_bind_impl(target, index_t<0>()); _bind_impl(target, ::sqlpp::detail::make_index_sequence<size::value>{});
} }
private: private:
template<size_t> struct index_t {}; // this is just for overloading template<typename Target, size_t... Is>
void _bind_impl(Target& target, const ::sqlpp::detail::index_sequence<Is...>&) const
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
{ {
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)...};
} }
}; };