Skip to content

Commit 1b9a4b1

Browse files
committed
Replace is_compatible function with class template
MSVC choked on that function (claimed that the number of arguments was incorrect)
1 parent 7c20a68 commit 1b9a4b1

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

include/sqlpp11/result_row.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,6 @@ namespace sqlpp
186186
using _impl = detail::result_row_impl<Db, _field_index_sequence, FieldSpecs...>;
187187
bool _is_valid;
188188

189-
template <typename D, typename... Fs>
190-
static constexpr auto is_compatible(detail::type_vector<result_row_t<D, Fs...>>) ->
191-
typename std::enable_if<sizeof...(Fs) == sizeof...(FieldSpecs), bool>::type
192-
{
193-
return logic::all_t<FieldSpecs::is_compatible(Fs{})...>::value;
194-
}
195-
196-
template <typename D, typename... Fs>
197-
static constexpr auto is_compatible(detail::type_vector<result_row_t<D, Fs...>>) ->
198-
typename std::enable_if<sizeof...(Fs) != sizeof...(FieldSpecs), bool>::type
199-
{
200-
return false;
201-
}
202189
result_row_t() : _impl(), _is_valid(false)
203190
{
204191
}
@@ -264,6 +251,20 @@ namespace sqlpp
264251
}
265252
};
266253

254+
template <typename Lhs, typename Rhs, typename Enable = void>
255+
struct is_result_compatible
256+
{
257+
static constexpr auto value = false;
258+
};
259+
260+
template <typename LDb, typename... LFields, typename RDb, typename... RFields>
261+
struct is_result_compatible<result_row_t<LDb, LFields...>,
262+
result_row_t<RDb, RFields...>,
263+
typename std::enable_if<sizeof...(LFields) == sizeof...(RFields)>::type>
264+
{
265+
static constexpr auto value = logic::all_t<LFields::is_compatible(RFields{})...>::value;
266+
};
267+
267268
template <typename Db, typename... FieldSpecs>
268269
struct dynamic_result_row_t
269270
: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>

include/sqlpp11/union.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ namespace sqlpp
215215

216216
using lhs_result_row_t = get_result_row_t<derived_statement_t<Policies>>;
217217
using rhs_result_row_t = get_result_row_t<Rhs>;
218-
constexpr auto vec_rhs = detail::type_vector<rhs_result_row_t>{};
219-
static_assert(lhs_result_row_t::is_compatible(vec_rhs),
218+
static_assert(is_result_compatible<lhs_result_row_t, rhs_result_row_t>::value,
220219
"both arguments in a union have to have the same result columns (type and name)");
221220

222221
return _union_impl<void, union_distinct_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
@@ -234,8 +233,7 @@ namespace sqlpp
234233

235234
using lhs_result_row_t = get_result_row_t<derived_statement_t<Policies>>;
236235
using rhs_result_row_t = get_result_row_t<Rhs>;
237-
constexpr auto vec_rhs = detail::type_vector<rhs_result_row_t>{};
238-
static_assert(lhs_result_row_t::is_compatible(vec_rhs),
236+
static_assert(is_result_compatible<lhs_result_row_t, rhs_result_row_t>::value,
239237
"both arguments in a union have to have the same result columns (type and name)");
240238

241239
return _union_impl<void, union_all_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);

0 commit comments

Comments
 (0)