mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Added several call dispatches to reduce compiler spew in case of errors
This commit is contained in:
parent
ad5584e52d
commit
bc5ffc1492
@ -39,23 +39,23 @@ namespace sqlpp
|
|||||||
template<>
|
template<>
|
||||||
struct all_impl<>
|
struct all_impl<>
|
||||||
{
|
{
|
||||||
static constexpr bool value = true;
|
using type = std::true_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool... Rest>
|
template<bool... Rest>
|
||||||
struct all_impl<true, Rest...>
|
struct all_impl<true, Rest...>
|
||||||
{
|
{
|
||||||
static constexpr bool value = all_impl<Rest...>::value;
|
using type = typename all_impl<Rest...>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool... Rest>
|
template<bool... Rest>
|
||||||
struct all_impl<false, Rest...>
|
struct all_impl<false, Rest...>
|
||||||
{
|
{
|
||||||
static constexpr bool value = false;
|
using type = std::false_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename> class Predicate, typename... T>
|
template<template<typename> class Predicate, typename... T>
|
||||||
using all_t = all_impl<Predicate<T>::value...>;
|
using all_t = typename all_impl<Predicate<T>::value...>::type;
|
||||||
|
|
||||||
template<bool... b>
|
template<bool... b>
|
||||||
struct any_impl;
|
struct any_impl;
|
||||||
@ -63,24 +63,27 @@ namespace sqlpp
|
|||||||
template<>
|
template<>
|
||||||
struct any_impl<>
|
struct any_impl<>
|
||||||
{
|
{
|
||||||
static constexpr bool value = false;
|
using type = std::false_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool... Rest>
|
template<bool... Rest>
|
||||||
struct any_impl<false, Rest...>
|
struct any_impl<false, Rest...>
|
||||||
{
|
{
|
||||||
static constexpr bool value = any_impl<Rest...>::value;
|
using type = typename all_impl<Rest...>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool... Rest>
|
template<bool... Rest>
|
||||||
struct any_impl<true, Rest...>
|
struct any_impl<true, Rest...>
|
||||||
{
|
{
|
||||||
static constexpr bool value = true;
|
using type = std::true_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename> class Predicate, typename... T>
|
template<template<typename> class Predicate, typename... T>
|
||||||
using any_t = any_impl<Predicate<T>::value...>;
|
using any_t = typename any_impl<Predicate<T>::value...>::type;
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using identity_t = T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,9 @@ namespace sqlpp
|
|||||||
using type = typename make_type_set<Rest...>::type::template insert<T>::type;
|
using type = typename make_type_set<Rest...>::type::template insert<T>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename... T>
|
||||||
|
using make_type_set_t = typename make_type_set<T...>::type;
|
||||||
|
|
||||||
template<template<typename> class Predicate, typename... T>
|
template<template<typename> class Predicate, typename... T>
|
||||||
struct make_type_set_if;
|
struct make_type_set_if;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ namespace sqlpp
|
|||||||
template<typename Needle, typename Replacement, typename... Policies>
|
template<typename Needle, typename Replacement, typename... Policies>
|
||||||
struct _policies_update_impl
|
struct _policies_update_impl
|
||||||
{
|
{
|
||||||
#warning: Need to make sure that Needle is in Policies!
|
static_assert(detail::is_element_of<Needle, make_type_set_t<Policies...>>::value, "policies update for non-policy class detected");
|
||||||
using type = select_t<Db, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
using type = select_t<Db, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
17
include/sqlpp11/vendor/from.h
vendored
17
include/sqlpp11/vendor/from.h
vendored
@ -70,10 +70,23 @@ namespace sqlpp
|
|||||||
template<typename Table>
|
template<typename Table>
|
||||||
void add_from(Table table)
|
void add_from(Table table)
|
||||||
{
|
{
|
||||||
static_assert(is_table_t<Table>::value, "invalid expression argument in add_from()");
|
static_assert(_is_dynamic::value, "add_from must not be called for static from()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
static_assert(is_table_t<Table>::value, "invalid table argument in add_from()");
|
||||||
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_table_t<Table>>;
|
||||||
|
|
||||||
|
_add_from_impl(table, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename Table>
|
||||||
|
void _add_from_impl(Table table, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_from._dynamic_tables.emplace_back(table);
|
return static_cast<typename Policies::_statement_t*>(this)->_from._dynamic_tables.emplace_back(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Table>
|
||||||
|
void _add_from_impl(Table table, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::tuple<Tables...> _tables;
|
std::tuple<Tables...> _tables;
|
||||||
|
14
include/sqlpp11/vendor/group_by.h
vendored
14
include/sqlpp11/vendor/group_by.h
vendored
@ -73,9 +73,21 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add_group_by must not be called for static group_by");
|
static_assert(_is_dynamic::value, "add_group_by must not be called for static group_by");
|
||||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_group_by()");
|
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_group_by()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_expression_t<Expression>>;
|
||||||
|
|
||||||
|
_add_group_by_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_group_by_impl(Expression expression, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_group_by._dynamic_expressions.emplace_back(expression);
|
return static_cast<typename Policies::_statement_t*>(this)->_group_by._dynamic_expressions.emplace_back(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_group_by_impl(Expression expression, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
const group_by_t& _group_by() const { return *this; }
|
const group_by_t& _group_by() const { return *this; }
|
||||||
|
14
include/sqlpp11/vendor/having.h
vendored
14
include/sqlpp11/vendor/having.h
vendored
@ -71,9 +71,21 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add_having must not be called for static having");
|
static_assert(_is_dynamic::value, "add_having must not be called for static having");
|
||||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_having()");
|
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_having()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_expression_t<Expression>>;
|
||||||
|
|
||||||
|
_add_having_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_having_impl(Expression expression, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_having._dynamic_expressions.emplace_back(expression);
|
return static_cast<typename Policies::_statement_t*>(this)->_having._dynamic_expressions.emplace_back(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_having_impl(Expression expression, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
|
14
include/sqlpp11/vendor/order_by.h
vendored
14
include/sqlpp11/vendor/order_by.h
vendored
@ -72,9 +72,21 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add_order_by must not be called for static order_by");
|
static_assert(_is_dynamic::value, "add_order_by must not be called for static order_by");
|
||||||
static_assert(is_sort_order_t<Expression>::value, "invalid expression argument in add_order_by()");
|
static_assert(is_sort_order_t<Expression>::value, "invalid expression argument in add_order_by()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_sort_order_t<Expression>>;
|
||||||
|
|
||||||
|
_add_order_by_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_order_by_impl(Expression expression, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_order_by._dynamic_expressions.emplace_back(expression);
|
return static_cast<typename Policies::_statement_t*>(this)->_order_by._dynamic_expressions.emplace_back(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_order_by_impl(Expression expression, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
|
14
include/sqlpp11/vendor/select_column_list.h
vendored
14
include/sqlpp11/vendor/select_column_list.h
vendored
@ -194,9 +194,21 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add_column can only be called for dynamic_column");
|
static_assert(_is_dynamic::value, "add_column can only be called for dynamic_column");
|
||||||
static_assert(is_named_expression_t<NamedExpression>::value, "invalid named expression argument in add_column()");
|
static_assert(is_named_expression_t<NamedExpression>::value, "invalid named expression argument in add_column()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_named_expression_t<NamedExpression>>;
|
||||||
|
|
||||||
|
_add_column_impl(namedExpression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename NamedExpression>
|
||||||
|
void _add_column_impl(NamedExpression namedExpression, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_column_list._dynamic_columns.emplace_back(namedExpression);
|
return static_cast<typename Policies::_statement_t*>(this)->_column_list._dynamic_columns.emplace_back(namedExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename NamedExpression>
|
||||||
|
void _add_column_impl(NamedExpression namedExpression, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
14
include/sqlpp11/vendor/select_flag_list.h
vendored
14
include/sqlpp11/vendor/select_flag_list.h
vendored
@ -69,9 +69,21 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add_flag must not be called for static select flags");
|
static_assert(_is_dynamic::value, "add_flag must not be called for static select flags");
|
||||||
static_assert(is_select_flag_t<Flag>::value, "invalid select flag argument in add_flag()");
|
static_assert(is_select_flag_t<Flag>::value, "invalid select flag argument in add_flag()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_select_flag_t<Flag>>;
|
||||||
|
|
||||||
|
_add_flag_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename Flag>
|
||||||
|
void _add_flag_impl(Flag flag, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_flag_list._dynamic_flags.emplace_back(flag);
|
return static_cast<typename Policies::_statement_t*>(this)->_flag_list._dynamic_flags.emplace_back(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Flag>
|
||||||
|
void _add_flag_impl(Flag flag, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
const select_flag_list_t& _flag_list() const { return *this; }
|
const select_flag_list_t& _flag_list() const { return *this; }
|
||||||
|
14
include/sqlpp11/vendor/where.h
vendored
14
include/sqlpp11/vendor/where.h
vendored
@ -72,9 +72,21 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add_where can only be called for dynamic_where");
|
static_assert(_is_dynamic::value, "add_where can only be called for dynamic_where");
|
||||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_where()");
|
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_where()");
|
||||||
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
|
||||||
|
using ok = ::sqlpp::detail::all_t<sqlpp::detail::identity_t, _is_dynamic, is_expression_t<Expression>>;
|
||||||
|
|
||||||
|
_add_where_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_where_impl(Expression expression, const std::true_type&)
|
||||||
|
{
|
||||||
return static_cast<typename Policies::_statement_t*>(this)->_where._dynamic_expressions.emplace_back(expression);
|
return static_cast<typename Policies::_statement_t*>(this)->_where._dynamic_expressions.emplace_back(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Expression>
|
||||||
|
void _add_where_impl(Expression expression, const std::false_type&);
|
||||||
};
|
};
|
||||||
|
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
|
Loading…
Reference in New Issue
Block a user