diff --git a/include/sqlpp11/core/clause/insert_value_list.h b/include/sqlpp11/core/clause/insert_value_list.h index 764abbf5..618a654f 100644 --- a/include/sqlpp11/core/clause/insert_value_list.h +++ b/include/sqlpp11/core/clause/insert_value_list.h @@ -106,7 +106,7 @@ namespace sqlpp private: template - auto columns_from_tuple(detail::index_sequence, std::tuple assignments) + auto columns_from_tuple(::sqlpp::index_sequence, std::tuple assignments) -> decltype(_columns) { (void)assignments; @@ -115,12 +115,12 @@ namespace sqlpp auto columns_from_tuple(std::tuple assignments) -> decltype(_columns) { - const auto seq = detail::make_index_sequence{}; + const auto seq = ::sqlpp::make_index_sequence{}; return columns_from_tuple(seq, assignments); } template - auto values_from_tuple(detail::index_sequence, std::tuple assignments) + auto values_from_tuple(::sqlpp::index_sequence, std::tuple assignments) -> decltype(_values) { (void)assignments; @@ -129,7 +129,7 @@ namespace sqlpp auto values_from_tuple(std::tuple assignments) -> decltype(_values) { - const auto seq = detail::make_index_sequence{}; + const auto seq = ::sqlpp::make_index_sequence{}; return values_from_tuple(seq, assignments); } }; diff --git a/include/sqlpp11/core/compat/string_view.h b/include/sqlpp11/core/compat/string_view.h index 90a2f2b5..de35dabf 100644 --- a/include/sqlpp11/core/compat/string_view.h +++ b/include/sqlpp11/core/compat/string_view.h @@ -62,8 +62,7 @@ namespace sqlpp { } -#warning: Can we make char_traits::length constexpr - constexpr string_view(const char* data) : _data(data), _size(std::char_traits::length(data)) + string_view(const char* data) : _data(data), _size(std::char_traits::length(data)) { } diff --git a/include/sqlpp11/core/detail/index_sequence.h b/include/sqlpp11/core/compat/utility.h similarity index 56% rename from include/sqlpp11/core/detail/index_sequence.h rename to include/sqlpp11/core/compat/utility.h index 74bbc4fc..a5e8dc4c 100644 --- a/include/sqlpp11/core/detail/index_sequence.h +++ b/include/sqlpp11/core/compat/utility.h @@ -1,7 +1,7 @@ #pragma once /* - * Copyright (c) 2013-2015, Roland Bock + * Copyright (c) 2013, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -26,35 +26,51 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include + +#ifdef _MSVC_LANG +#define CXX_STD_VER _MSVC_LANG +#else +#define CXX_STD_VER __cplusplus +#endif + +#if CXX_STD_VER >= 201402L +#include +namespace sqlpp +{ + template + using index_sequence = std::index_sequence; + template + using make_index_sequence = std::make_index_sequence; + +} // namespace sqlpp + +#else // incomplete backport of utility.h namespace sqlpp { - namespace detail + template + class index_sequence { - // Note: This is a minimalistic implementation of index_sequence available in C++14 - // It should be replaced once the project is moved to C++14 or beyond - template - struct index_sequence - { - }; + }; - template - struct make_index_sequence_impl; + template + struct make_index_sequence_impl; - template - struct make_index_sequence_impl, N> - { - using type = typename make_index_sequence_impl, N - 1>::type; - }; + template + struct make_index_sequence_impl, N> + { + using type = typename make_index_sequence_impl, N - 1>::type; + }; - template - struct make_index_sequence_impl, 0> - { - using type = index_sequence; - }; + template + struct make_index_sequence_impl, 0> + { + using type = index_sequence; + }; - template - using make_index_sequence = typename make_index_sequence_impl, N>::type; - } // namespace detail + template + using make_index_sequence = typename make_index_sequence_impl, N>::type; } // namespace sqlpp + +#endif diff --git a/include/sqlpp11/core/database/parameter_list.h b/include/sqlpp11/core/database/parameter_list.h index c7416936..51bead7e 100644 --- a/include/sqlpp11/core/database/parameter_list.h +++ b/include/sqlpp11/core/database/parameter_list.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include namespace sqlpp @@ -52,12 +52,12 @@ namespace sqlpp template void _bind(Target& target) const { - _bind_impl(target, detail::make_index_sequence{}); + _bind_impl(target, ::sqlpp::make_index_sequence{}); } private: template - void _bind_impl(Target& target, const detail::index_sequence& /*unused*/) const + void _bind_impl(Target& target, const ::sqlpp::index_sequence& /*unused*/) const { using swallow = int[]; // see core/interpret_tuple.h (void)swallow{0, (std::tuple_element::type::operator()()._bind(target, Is), 0)...}; diff --git a/include/sqlpp11/core/interpret_tuple.h b/include/sqlpp11/core/interpret_tuple.h index 0f314291..d0210110 100644 --- a/include/sqlpp11/core/interpret_tuple.h +++ b/include/sqlpp11/core/interpret_tuple.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -56,7 +56,7 @@ namespace sqlpp const Separator& separator, Context& context, const UseBraces& useBraces, - const detail::index_sequence & + const ::sqlpp::index_sequence & /*unused*/) -> Context& { // Note: A braced-init-list does guarantee the order of evaluation according to 12.6.1 [class.explicit.init] @@ -75,13 +75,13 @@ namespace sqlpp auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context) -> Context& { return interpret_tuple_impl(t, separator, context, std::true_type{}, - detail::make_index_sequence::value>{}); + ::sqlpp::make_index_sequence::value>{}); } template auto interpret_tuple_without_braces(const Tuple& t, const Separator& separator, Context& context) -> Context& { return interpret_tuple_impl(t, separator, context, std::false_type{}, - detail::make_index_sequence::value>{}); + ::sqlpp::make_index_sequence::value>{}); } } // namespace sqlpp diff --git a/include/sqlpp11/core/name/char_sequence.h b/include/sqlpp11/core/name/char_sequence.h index 6999aa4a..ad256aa5 100644 --- a/include/sqlpp11/core/name/char_sequence.h +++ b/include/sqlpp11/core/name/char_sequence.h @@ -1,7 +1,7 @@ #pragma once /* - * Copyright (c) 2013-2015, Roland Bock + * Copyright (c) 2013, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -27,8 +27,7 @@ */ #include -#warning: move index_sequence into compat -#include +#include namespace sqlpp { @@ -41,13 +40,13 @@ namespace sqlpp struct make_char_sequence_impl; template - struct make_char_sequence_impl> + struct make_char_sequence_impl> { using type = char_sequence; }; template using make_char_sequence = - typename make_char_sequence_impl>::type; + typename make_char_sequence_impl>::type; } // namespace sqlpp diff --git a/include/sqlpp11/core/query/result_row.h b/include/sqlpp11/core/query/result_row.h index 5961a52a..26ad6a8f 100644 --- a/include/sqlpp11/core/query/result_row.h +++ b/include/sqlpp11/core/query/result_row.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include @@ -72,7 +72,7 @@ namespace sqlpp }; template - struct result_row_impl, FieldSpecs...> + struct result_row_impl, FieldSpecs...> : public result_field... { result_row_impl() = default; @@ -109,9 +109,9 @@ namespace sqlpp template struct result_row_t - : public detail::result_row_impl, FieldSpecs...> + : public detail::result_row_impl, FieldSpecs...> { - using _impl = detail::result_row_impl, FieldSpecs...>; + using _impl = detail::result_row_impl, FieldSpecs...>; bool _is_valid{false}; result_row_t() : _impl()