diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index d35c687d..71461aba 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -166,32 +166,43 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto flags(Flags... flags) const - -> _new_statement_t> + -> _new_statement_t<_check, select_flag_list_t> { - return _flags_impl(flags...); + static_assert(_check::value, "at least one argument is not a select flag in select flag list"); + + return _flags_impl(_check{}, flags...); } template auto dynamic_flags(Flags... flags) const - -> _new_statement_t> + -> _new_statement_t<_check, select_flag_list_t<_database_t, Flags...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_flags must not be called in a static statement"); - return _flags_impl<_database_t>(flags...); + static_assert(_check::value, "at least one argument is not a select flag in select flag list"); + + return _flags_impl<_database_t>(_check{}, flags...); } private: template - auto _flags_impl(Flags... flags) const - -> _new_statement_t> + auto _flags_impl(const std::false_type&, Flags... flags) const + -> bad_statement; + + template + auto _flags_impl(const std::true_type&, Flags... flags) const + -> _new_statement_t> { - static_assert(detail::all_t::value...>::value, "at least one argument is not a select flag in select flag list"); static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); return { static_cast&>(*this), select_flag_list_data_t{flags...} };