diff --git a/include/sqlpp11/all_of.h b/include/sqlpp11/all_of.h index 4c4076cd..32dacf55 100644 --- a/include/sqlpp11/all_of.h +++ b/include/sqlpp11/all_of.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace sqlpp { @@ -51,16 +52,7 @@ namespace sqlpp return {}; } - struct assert_no_stand_alone_all_of_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "all_of(table) seems to be used outside of select"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_no_stand_alone_all_of_t, "all_of(table) seems to be used outside of select"); template struct serializer_t> diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 21f1360d..cf57a85e 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -55,17 +55,9 @@ namespace sqlpp interpretable_list_t _dynamic_expressions; }; - struct assert_no_unknown_tables_in_group_by_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "at least one group-by expression requires a table which is otherwise not known in the statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_tables_in_group_by_t, + "at least one group-by expression requires a table which is otherwise not known in the statement"); // GROUP BY template diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index f9d5bc9b..f1720f16 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -54,17 +54,9 @@ namespace sqlpp interpretable_list_t _dynamic_expressions; }; - struct assert_no_unknown_tables_in_having_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "at least one having-expression requires a table which is otherwise not known in the statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_tables_in_having_t, + "at least one having-expression requires a table which is otherwise not known in the statement"); // HAVING template diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index e1322c05..608d4794 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -274,17 +274,8 @@ namespace sqlpp std::vector<_value_tuple_t> _insert_values; }; - struct assert_no_unknown_tables_in_column_list_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "at least one column requires a table which is otherwise not known in the statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_no_unknown_tables_in_column_list_t, + "at least one column requires a table which is otherwise not known in the statement"); template struct column_list_t @@ -357,16 +348,7 @@ namespace sqlpp }; }; - struct assert_insert_values_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "insert values required, e.g. set(...) or default_values()"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_insert_values_t, "insert values required, e.g. set(...) or default_values()"); // NO INSERT COLUMNS/VALUES YET struct no_insert_value_list_t diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index f420ab57..c548a081 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -100,16 +100,7 @@ namespace sqlpp }; }; - struct assert_into_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "into() required"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_into_t, "into() required"); // NO INTO YET struct no_into_t diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index 5265639c..5020b240 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -55,17 +55,9 @@ namespace sqlpp interpretable_list_t _dynamic_expressions; }; - struct assert_no_unknown_tables_in_order_by_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "at least one order-by expression requires a table which is otherwise not known in the statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_tables_in_order_by_t, + "at least one order-by expression requires a table which is otherwise not known in the statement"); // ORDER BY template diff --git a/include/sqlpp11/portable_static_assert.h b/include/sqlpp11/portable_static_assert.h index 6b895a2c..bf7d3e22 100644 --- a/include/sqlpp11/portable_static_assert.h +++ b/include/sqlpp11/portable_static_assert.h @@ -27,6 +27,8 @@ #ifndef SQLPP_PORTABLE_STATIC_ASSERT_H #define SQLPP_PORTABLE_STATIC_ASSERT_H +#include + namespace sqlpp { #define SQLPP_PORTABLE_STATIC_ASSERT(name, message) \ diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 40a94d4b..e4f5d497 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -156,28 +156,11 @@ namespace sqlpp dynamic_select_column_list _dynamic_columns; }; - struct assert_no_unknown_tables_in_selected_columns_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "at least one selected column requires a table which is otherwise not known in the statement"); - } - }; - - struct assert_aggregates_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "not all columns are made of aggregates, despite group_by or similar"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_tables_in_selected_columns_t, + "at least one selected column requires a table which is otherwise not known in the statement"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_aggregates_t, + "not all columns are made of aggregates, despite group_by or similar"); // SELECTED COLUMNS template diff --git a/include/sqlpp11/serializer.h b/include/sqlpp11/serializer.h index a522f49a..14f9a884 100644 --- a/include/sqlpp11/serializer.h +++ b/include/sqlpp11/serializer.h @@ -28,19 +28,11 @@ #define SQLPP_SERIALIZER_H #include +#include namespace sqlpp { - struct assert_serializer_specialization_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "missing serializer specialization"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_serializer_specialization_t, "missing serializer specialization"); template struct serializer_t diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index b8e48769..4800294b 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -44,39 +44,13 @@ namespace sqlpp template struct statement_t; - struct assert_no_unknown_ctes_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "one clause requires common table expressions which are otherwise not known in the statement"); - } - }; - - struct assert_no_unknown_tables_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "one clause requires tables which are otherwise not known in the statement"); - } - }; - - struct assert_no_parameters_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "cannot run statements with parameters directly, use prepare instead"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_ctes_t, + "one clause requires common table expressions which are otherwise not known in the statement"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_no_unknown_tables_t, + "one clause requires tables which are otherwise not known in the statement"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_no_parameters_t, + "cannot run statements with parameters directly, use prepare instead"); namespace detail { diff --git a/include/sqlpp11/tvin.h b/include/sqlpp11/tvin.h index c3241306..40e01e1c 100644 --- a/include/sqlpp11/tvin.h +++ b/include/sqlpp11/tvin.h @@ -56,16 +56,8 @@ namespace sqlpp _operand_t _value; }; - struct assert_tvin_with_correct_operator_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "tvin may only be used with operators =, == and !="); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_tvin_with_correct_operator_t, + "tvin may only be used with operators =, == and !="); template struct serializer_t> diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 2d6a4a08..1b413161 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -373,28 +373,10 @@ namespace sqlpp using serialize_check_of = detail::get_first_if::_serialize_check...>; - struct assert_run_statement_or_prepared_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "connection cannot run something that is neither statement nor prepared statement"); - } - }; - - struct assert_prepare_statement_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "connection cannot prepare something that is not a statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_run_statement_or_prepared_t, + "connection cannot run something that is neither statement nor prepared statement"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_prepare_statement_t, + "connection cannot prepare something that is not a statement"); template struct consistency_check diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 9f442852..8f513cc3 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -52,17 +52,9 @@ namespace sqlpp interpretable_list_t _dynamic_assignments; }; - struct assert_no_unknown_tables_in_update_assignments_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, - "at least one update assignment requires a table which is otherwise not known in the statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_tables_in_update_assignments_t, + "at least one update assignment requires a table which is otherwise not known in the statement"); // UPDATE ASSIGNMENTS template @@ -146,16 +138,7 @@ namespace sqlpp }; }; - struct assert_update_assignments_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "update assignments required, i.e. set(...)"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_update_assignments_t, "update assignments required, i.e. set(...)"); struct no_update_list_t { diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index cc1dbbab..7f52003a 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -55,18 +55,9 @@ namespace sqlpp interpretable_list_t _dynamic_expressions; }; - struct assert_no_unknown_tables_in_where_t - { - using type = std::false_type; - - template - static void _() - { - static_assert( - wrong_t::value, - "at least one expression in where() requires a table which is otherwise not known in the statement"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT( + assert_no_unknown_tables_in_where_t, + "at least one expression in where() requires a table which is otherwise not known in the statement"); // WHERE(EXPR) template @@ -198,16 +189,7 @@ namespace sqlpp }; }; - struct assert_where_t - { - using type = std::false_type; - - template - static void _() - { - static_assert(wrong_t::value, "where expression required, e.g. where(true)"); - } - }; + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_t, "where expression required, e.g. where(true)"); SQLPP_PORTABLE_STATIC_ASSERT(assert_where_expressions_t, "at least one argument is not a boolean expression in where()");