0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

More moves

And introduced sqlpp::enable_if_t
This commit is contained in:
Roland Bock 2024-07-30 06:45:00 +02:00
parent 79da114c00
commit b9eca7db17
39 changed files with 126 additions and 66 deletions

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_over.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/aggregate_function/enable_over.h>
#include <sqlpp11/core/type_traits.h>
namespace sqlpp
@ -74,7 +74,7 @@ namespace sqlpp
template <typename T>
using check_avg_arg =
std::enable_if_t<(is_numeric<T>::value or is_boolean<T>::value) and not contains_aggregate_function_t<T>::value>;
::sqlpp::enable_if_t<(is_numeric<T>::value or is_boolean<T>::value) and not contains_aggregate_function_t<T>::value>;
template <typename T, typename = check_avg_arg<T>>
auto avg(T t) -> avg_t<noop, T>

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_over.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/aggregate_function/enable_over.h>
#include <sqlpp11/core/clause/select_flags.h>
#include <sqlpp11/core/type_traits.h>
@ -77,7 +77,7 @@ namespace sqlpp
template <typename T>
using check_count_arg =
std::enable_if_t<values_are_comparable<T, T>::value and not contains_aggregate_function_t<T>::value>;
::sqlpp::enable_if_t<values_are_comparable<T, T>::value and not contains_aggregate_function_t<T>::value>;
template <typename T, typename = check_count_arg<T>>
auto count(T t) -> count_t<noop, T>

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_over.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/aggregate_function/enable_over.h>
#include <sqlpp11/core/clause/select_flags.h>
#include <sqlpp11/core/type_traits.h>
@ -76,7 +76,7 @@ namespace sqlpp
template <typename T>
using check_max_arg =
std::enable_if_t<values_are_comparable<T, T>::value and not contains_aggregate_function_t<T>::value>;
::sqlpp::enable_if_t<values_are_comparable<T, T>::value and not contains_aggregate_function_t<T>::value>;
template <typename T, typename = check_max_arg<T>>
auto max(T t) -> max_t<noop, T>

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_over.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/aggregate_function/enable_over.h>
#include <sqlpp11/core/clause/select_flags.h>
#include <sqlpp11/core/type_traits.h>
@ -76,7 +76,7 @@ namespace sqlpp
template <typename T>
using check_min_arg =
std::enable_if_t<values_are_comparable<T, T>::value and not contains_aggregate_function_t<T>::value>;
::sqlpp::enable_if_t<values_are_comparable<T, T>::value and not contains_aggregate_function_t<T>::value>;
template <typename T, typename = check_min_arg<T>>
auto min(T t) -> min_t<noop, T>

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_comparison.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/operator/enable_comparison.h>
#include <sqlpp11/core/type_traits.h>
namespace sqlpp
@ -59,7 +59,7 @@ namespace sqlpp
struct nodes_of<over_t<Expr>>: public nodes_of<Expr> {};
template<typename Expr>
using check_over_args = std::enable_if_t<contains_aggregate_function_t<Expr>::value>;
using check_over_args = ::sqlpp::enable_if_t<contains_aggregate_function_t<Expr>::value>;
template <typename Context, typename Expr>
Context& serialize(Context& context, const over_t<Expr>& t)

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_over.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/aggregate_function/enable_over.h>
#include <sqlpp11/core/clause/select_flags.h>
#include <sqlpp11/core/type_traits.h>
@ -77,7 +77,7 @@ namespace sqlpp
template <typename T>
using check_sum_arg =
std::enable_if_t<(is_numeric<T>::value or is_boolean<T>::value) and not contains_aggregate_function_t<T>::value>;
::sqlpp::enable_if_t<(is_numeric<T>::value or is_boolean<T>::value) and not contains_aggregate_function_t<T>::value>;
template <typename T, typename = check_sum_arg<T>>
auto sum(T t) -> sum_t<noop, T>

View File

@ -26,8 +26,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_comparison.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/operator/enable_comparison.h>
#include <sqlpp11/core/operator/as_expression.h>
#include <sqlpp11/core/operator/assign_expression.h>
#include <sqlpp11/core/basic/column_fwd.h>

View File

@ -26,7 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_comparison.h>
#include <sqlpp11/core/operator/enable_comparison.h>
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/alias_provider.h>
#include <sqlpp11/core/detail/type_set.h>

View File

@ -26,7 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_join.h>
#include <sqlpp11/core/basic/enable_join.h>
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/basic/table_alias.h>
#include <sqlpp11/core/basic/all_of.h>

View File

@ -26,7 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_join.h>
#include <sqlpp11/core/basic/enable_join.h>
#include <sqlpp11/core/basic/table_columns.h>
#include <sqlpp11/core/detail/type_set.h>
#include <sqlpp11/core/serialize.h>

View File

@ -50,7 +50,7 @@ namespace sqlpp
};
template <typename T>
using check_value_arg = std::enable_if_t<not std::is_same<value_type_of_t<T>, no_value_t>::value and values_are_comparable<T, T>::value>;
using check_value_arg = ::sqlpp::enable_if_t<not std::is_same<value_type_of_t<T>, no_value_t>::value and values_are_comparable<T, T>::value>;
template <typename Context, typename T>
Context& serialize(Context& context, const value_t<T>& t)

View File

@ -28,7 +28,7 @@
#include <utility>
#include <sqlpp11/core/enable_join.h>
#include <sqlpp11/core/basic/enable_join.h>
#include <sqlpp11/core/type_traits.h>
namespace sqlpp

View File

@ -34,7 +34,7 @@
#include <sqlpp11/core/no_data.h>
#include <sqlpp11/core/query/policy_update.h>
#include <sqlpp11/core/portable_static_assert.h>
#include <sqlpp11/core/simple_column.h>
#include <sqlpp11/core/clause/simple_column.h>
#include <sqlpp11/core/query/statement.h>
#include <sqlpp11/core/type_traits.h>

View File

@ -27,8 +27,8 @@
*/
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_join.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/basic/enable_join.h>
namespace sqlpp
{

View File

@ -31,7 +31,7 @@
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/parameter_list.h>
#include <sqlpp11/core/database/prepared_update.h>
#include <sqlpp11/core/single_table.h>
#include <sqlpp11/core/clause/single_table.h>
#include <sqlpp11/core/clause/update_list.h>
#include <sqlpp11/core/noop.h>
#include <sqlpp11/core/clause/where.h>

View File

@ -34,15 +34,23 @@
#define CXX_STD_VER __cplusplus
#endif
#if CXX_STD_VER >= 201402L
namespace sqlpp
{
using ::std::make_unique;
}
#else
namespace sqlpp
{
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
#if CXX_STD_VER >= 201402L
return std::make_unique<T>(std::forward<Args>(args)...);
#else
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
#endif
}
} // namespace sqlpp
#endif

View File

@ -0,0 +1,51 @@
#pragma once
/*
* Copyright (c) 2024, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <type_traits>
#ifdef _MSVC_LANG
#define CXX_STD_VER _MSVC_LANG
#else
#define CXX_STD_VER __cplusplus
#endif
#if CXX_STD_VER >= 201703L
namespace sqlpp
{
using ::std::enable_if_t;
} // namespace sqlpp
#else
namespace sqlpp
{
template <bool Condition, typename Type = void>
using enable_if_t = typename ::std::enable_if<Condition, Type>::type;
} // namespace sqlpp
#endif

View File

@ -61,7 +61,7 @@ namespace sqlpp
}
template<typename T>
using check_lower_args = std::enable_if_t<is_text<T>::value>;
using check_lower_args = ::sqlpp::enable_if_t<is_text<T>::value>;
template <typename T, typename = check_lower_args<T>>
auto lower(T t) -> lower_t<T>

View File

@ -69,7 +69,7 @@ namespace sqlpp
}
template<typename T>
using check_trim_args = std::enable_if_t<is_text<T>::value>;
using check_trim_args = ::sqlpp::enable_if_t<is_text<T>::value>;
template <typename T, typename = check_trim_args<T>>
auto trim(T t) -> trim_t<T>

View File

@ -61,7 +61,7 @@ namespace sqlpp
}
template<typename T>
using check_upper_args = std::enable_if_t<is_text<T>::value>;
using check_upper_args = ::sqlpp::enable_if_t<is_text<T>::value>;
template <typename T, typename = check_upper_args<T>>
auto upper(T t) -> upper_t<T>

View File

@ -80,7 +80,7 @@ namespace sqlpp
}
template <typename Select>
using check_any_args = std::enable_if_t<has_value_type<Select>::value>;
using check_any_args = ::sqlpp::enable_if_t<has_value_type<Select>::value>;
template <typename ...Policies, typename = check_any_args<statement_t<Policies...>>>
auto any(statement_t<Policies...> t) -> any_t<statement_t<Policies...>>

View File

@ -29,8 +29,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include <sqlpp11/core/noop.h>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/enable_comparison.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/operator/enable_comparison.h>
#include <sqlpp11/core/type_traits.h>
namespace sqlpp
@ -56,7 +56,7 @@ namespace sqlpp
};
template <typename L, typename R>
using check_arithmetic_args = std::enable_if_t<is_numeric<L>::value and is_numeric<R>::value>;
using check_arithmetic_args = ::sqlpp::enable_if_t<is_numeric<L>::value and is_numeric<R>::value>;
#warning: need to document that this is on purpose (not integral, or unsigned integral, or floating_point) because it is difficult to know for the library to know what the actual result type will be (it is difficult to guess in C++ already, and it is probably different from DB vendor to vendor).
template <typename L, typename Operator, typename R>
@ -142,7 +142,7 @@ namespace sqlpp
}
template <typename L, typename R>
using check_concatenation_args = std::enable_if_t<is_text<L>::value and is_text<R>::value>;
using check_concatenation_args = ::sqlpp::enable_if_t<is_text<L>::value and is_text<R>::value>;
template <typename L, typename R, typename = check_concatenation_args<L, R>>
constexpr auto operator+(L l, R r) -> arithmetic_expression<L, concatenation, R>
@ -200,7 +200,7 @@ namespace sqlpp
};
template <typename L, typename R>
using check_modulus_args = std::enable_if_t<(is_integral<L>::value or is_unsigned_integral<L>::value) and (is_integral<R>::value or is_unsigned_integral<R>::value)>;
using check_modulus_args = ::sqlpp::enable_if_t<(is_integral<L>::value or is_unsigned_integral<L>::value) and (is_integral<R>::value or is_unsigned_integral<R>::value)>;
template <typename L, typename R, typename = check_modulus_args<L, R>>
constexpr auto operator%(L l, R r) -> arithmetic_expression<L, modulus, R>

View File

@ -73,7 +73,7 @@ namespace sqlpp
return context;
}
template <typename Expr, typename AliasProvider>
using check_as_args = std::enable_if_t<
using check_as_args = ::sqlpp::enable_if_t<
has_value_type<Expr>::value and not is_alias_t<Expr>::value and has_name<AliasProvider>::value
>;

View File

@ -51,10 +51,10 @@ namespace sqlpp
template <typename L, typename R>
using check_assign_args =
std::enable_if_t<values_are_comparable<L, R>::value and (can_be_null<L>::value or not can_be_null<R>::value)>;
::sqlpp::enable_if_t<values_are_comparable<L, R>::value and (can_be_null<L>::value or not can_be_null<R>::value)>;
template <typename L>
using check_assign_default_args = std::enable_if_t<has_default<L>::value>;
using check_assign_default_args = ::sqlpp::enable_if_t<has_default<L>::value>;
template <typename L, typename Operator, typename R>
struct is_assignment<assign_expression<L, Operator, R>> : public std::true_type {};

View File

@ -26,7 +26,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/logic.h>
@ -49,7 +49,7 @@ namespace sqlpp
template <typename L, typename R1, typename R2>
using check_between_args =
std::enable_if_t<values_are_comparable<L, R1>::value and values_are_comparable<L, R2>::value>;
::sqlpp::enable_if_t<values_are_comparable<L, R1>::value and values_are_comparable<L, R2>::value>;
template <typename L, typename R1, typename R2>
struct value_type_of<between_expression<L, R1, R2>>
@ -78,7 +78,7 @@ namespace sqlpp
template <typename L, typename... Args>
constexpr auto in(L l, Args... args)
-> std::enable_if_t<((sizeof...(Args) > 0) and ... and values_are_compatible_v<L, Args>), between_t<L, Args...>>
-> ::sqlpp::enable_if_t<((sizeof...(Args) > 0) and ... and values_are_compatible_v<L, Args>), between_t<L, Args...>>
{
return between_t<L, Args...>{l, std::tuple{args...}};
}

View File

@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <type_traits>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/noop.h>
#include <sqlpp11/core/type_traits.h>
@ -65,7 +65,7 @@ namespace sqlpp
};
template <typename L, typename R>
using check_bit_expression_args = std::enable_if_t<is_integral<L>::value and (is_integral<R>::value or is_unsigned_integral<R>::value)>;
using check_bit_expression_args = ::sqlpp::enable_if_t<is_integral<L>::value and (is_integral<R>::value or is_unsigned_integral<R>::value)>;
#if 0
template <typename L, typename Operator, typename R>

View File

@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/operator/any.h>
#include <sqlpp11/core/noop.h>
#include <sqlpp11/core/type_traits.h>
@ -50,7 +50,7 @@ namespace sqlpp
};
template <typename L, typename R>
using check_comparison_args = std::enable_if_t<values_are_comparable<L, R>::value>;
using check_comparison_args = ::sqlpp::enable_if_t<values_are_comparable<L, R>::value>;
template <typename L, typename Operator, typename R>
struct value_type_of<comparison_expression<L, Operator, R>>
@ -258,7 +258,7 @@ namespace sqlpp
};
template <typename L, typename R>
using check_like_args = std::enable_if_t<is_text<L>::value and is_text<R>::value>;
using check_like_args = ::sqlpp::enable_if_t<is_text<L>::value and is_text<R>::value>;
template <typename L, typename R, typename = check_comparison_args<L, R>>
constexpr auto like(L l, R r) -> comparison_expression<L, op_like, R>

View File

@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <type_traits>
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
namespace sqlpp
{
@ -49,7 +49,7 @@ namespace sqlpp
};
template <typename Select>
using check_exists_arg = std::enable_if_t<is_statement_t<Select>::value and has_result_row_t<Select>::value>;
using check_exists_arg = ::sqlpp::enable_if_t<is_statement_t<Select>::value and has_result_row_t<Select>::value>;
template <typename Select>
struct value_type_of<exists_expression<Select>>

View File

@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <tuple>
#include <vector>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/logic.h>
#include <sqlpp11/core/interpret_tuple.h>
@ -70,7 +70,7 @@ namespace sqlpp
template <typename L, typename... Args>
using check_in_args =
std::enable_if_t<(sizeof...(Args) != 0) and logic::all_t<values_are_comparable<L, Args>::value...>::value>;
::sqlpp::enable_if_t<(sizeof...(Args) != 0) and logic::all_t<values_are_comparable<L, Args>::value...>::value>;
template <typename L, typename Operator, typename R>
struct value_type_of<in_expression<L, Operator, std::vector<R>>>

View File

@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <type_traits>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/query/dynamic.h>
#include <sqlpp11/core/noop.h>
//#include <sqlpp11/embrace.h>
@ -55,7 +55,7 @@ namespace sqlpp
};
template <typename L, typename R>
using check_logical_args = std::enable_if_t<is_boolean<L>::value and is_boolean<R>::value>;
using check_logical_args = ::sqlpp::enable_if_t<is_boolean<L>::value and is_boolean<R>::value>;
template <typename L, typename Operator, typename R>
struct value_type_of<logical_expression<L, Operator, R>>

View File

@ -55,7 +55,7 @@ namespace sqlpp
};
template <typename L>
using check_sort_order_args = std::enable_if_t<values_are_comparable<L, L>::value>;
using check_sort_order_args = ::sqlpp::enable_if_t<values_are_comparable<L, L>::value>;
template <typename L>
struct nodes_of<sort_order_expression<L>>

View File

@ -27,7 +27,7 @@
*/
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/enable_as.h>
#include <sqlpp11/core/operator/enable_as.h>
#include <sqlpp11/core/serialize.h>
namespace sqlpp
@ -88,7 +88,7 @@ namespace sqlpp
}
template <typename Expr>
using check_dynamic_args = std::enable_if_t<has_value_type<Expr>::value>;
using check_dynamic_args = ::sqlpp::enable_if_t<has_value_type<Expr>::value>;
template <typename Expr, typename = check_dynamic_args<Expr>>
auto dynamic(bool condition, Expr t) -> dynamic_t<Expr>

View File

@ -36,6 +36,7 @@
#include <sqlpp11/core/name_tag.h>
#include <sqlpp11/core/compat/optional.h>
#include <sqlpp11/core/compat/string_view.h>
#include <sqlpp11/core/compat/type_traits.h>
#include <sqlpp11/core/compat/span.h>
#include <sqlpp11/core/consistent.h>
#include <sqlpp11/core/portable_static_assert.h>