mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Replace is_compatible function with class template
MSVC choked on that function (claimed that the number of arguments was incorrect)
This commit is contained in:
parent
7c20a68e0b
commit
1b9a4b1594
@ -186,19 +186,6 @@ namespace sqlpp
|
|||||||
using _impl = detail::result_row_impl<Db, _field_index_sequence, FieldSpecs...>;
|
using _impl = detail::result_row_impl<Db, _field_index_sequence, FieldSpecs...>;
|
||||||
bool _is_valid;
|
bool _is_valid;
|
||||||
|
|
||||||
template <typename D, typename... Fs>
|
|
||||||
static constexpr auto is_compatible(detail::type_vector<result_row_t<D, Fs...>>) ->
|
|
||||||
typename std::enable_if<sizeof...(Fs) == sizeof...(FieldSpecs), bool>::type
|
|
||||||
{
|
|
||||||
return logic::all_t<FieldSpecs::is_compatible(Fs{})...>::value;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename D, typename... Fs>
|
|
||||||
static constexpr auto is_compatible(detail::type_vector<result_row_t<D, Fs...>>) ->
|
|
||||||
typename std::enable_if<sizeof...(Fs) != sizeof...(FieldSpecs), bool>::type
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
result_row_t() : _impl(), _is_valid(false)
|
result_row_t() : _impl(), _is_valid(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -264,6 +251,20 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Lhs, typename Rhs, typename Enable = void>
|
||||||
|
struct is_result_compatible
|
||||||
|
{
|
||||||
|
static constexpr auto value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename LDb, typename... LFields, typename RDb, typename... RFields>
|
||||||
|
struct is_result_compatible<result_row_t<LDb, LFields...>,
|
||||||
|
result_row_t<RDb, RFields...>,
|
||||||
|
typename std::enable_if<sizeof...(LFields) == sizeof...(RFields)>::type>
|
||||||
|
{
|
||||||
|
static constexpr auto value = logic::all_t<LFields::is_compatible(RFields{})...>::value;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Db, typename... FieldSpecs>
|
template <typename Db, typename... FieldSpecs>
|
||||||
struct dynamic_result_row_t
|
struct dynamic_result_row_t
|
||||||
: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>
|
: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>
|
||||||
|
@ -215,8 +215,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
using lhs_result_row_t = get_result_row_t<derived_statement_t<Policies>>;
|
using lhs_result_row_t = get_result_row_t<derived_statement_t<Policies>>;
|
||||||
using rhs_result_row_t = get_result_row_t<Rhs>;
|
using rhs_result_row_t = get_result_row_t<Rhs>;
|
||||||
constexpr auto vec_rhs = detail::type_vector<rhs_result_row_t>{};
|
static_assert(is_result_compatible<lhs_result_row_t, rhs_result_row_t>::value,
|
||||||
static_assert(lhs_result_row_t::is_compatible(vec_rhs),
|
|
||||||
"both arguments in a union have to have the same result columns (type and name)");
|
"both arguments in a union have to have the same result columns (type and name)");
|
||||||
|
|
||||||
return _union_impl<void, union_distinct_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
|
return _union_impl<void, union_distinct_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
|
||||||
@ -234,8 +233,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
using lhs_result_row_t = get_result_row_t<derived_statement_t<Policies>>;
|
using lhs_result_row_t = get_result_row_t<derived_statement_t<Policies>>;
|
||||||
using rhs_result_row_t = get_result_row_t<Rhs>;
|
using rhs_result_row_t = get_result_row_t<Rhs>;
|
||||||
constexpr auto vec_rhs = detail::type_vector<rhs_result_row_t>{};
|
static_assert(is_result_compatible<lhs_result_row_t, rhs_result_row_t>::value,
|
||||||
static_assert(lhs_result_row_t::is_compatible(vec_rhs),
|
|
||||||
"both arguments in a union have to have the same result columns (type and name)");
|
"both arguments in a union have to have the same result columns (type and name)");
|
||||||
|
|
||||||
return _union_impl<void, union_all_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
|
return _union_impl<void, union_all_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
|
||||||
|
Loading…
Reference in New Issue
Block a user