From ac3a8290ffac0f694e6c0a9930c11dd24f71e893 Mon Sep 17 00:00:00 2001 From: Daniel Evers Date: Thu, 24 Jan 2019 15:08:43 +0100 Subject: [PATCH] support for std::string_view when using C++17 --- include/sqlpp11/data_types/text/operand.h | 13 +++++++++++++ include/sqlpp11/data_types/text/wrap_operand.h | 11 ++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/data_types/text/operand.h b/include/sqlpp11/data_types/text/operand.h index fc2fda1c..1bf169be 100644 --- a/include/sqlpp11/data_types/text/operand.h +++ b/include/sqlpp11/data_types/text/operand.h @@ -29,6 +29,9 @@ #include #include +#if __cplusplus >= 201703L +#include +#endif #include #include #include @@ -50,6 +53,16 @@ namespace sqlpp text_operand(_value_t t) : _t(std::move(t)) { } +#if __cplusplus >= 201703L + // allow construction from an std::string_view + text_operand(std::string_view t) : _t(t) + { + } + // additional const char* overload, required to disambiguate + text_operand(const char* t) : _t(t) + { + } +#endif text_operand(const text_operand&) = default; text_operand(text_operand&&) = default; diff --git a/include/sqlpp11/data_types/text/wrap_operand.h b/include/sqlpp11/data_types/text/wrap_operand.h index c2318e43..7a8f8a9f 100644 --- a/include/sqlpp11/data_types/text/wrap_operand.h +++ b/include/sqlpp11/data_types/text/wrap_operand.h @@ -28,6 +28,9 @@ #define SQLPP11_DATA_TYPES_TEXT_WRAP_OPERAND_H #include +#if __cplusplus >= 201703L +#include +#endif #include #include @@ -35,10 +38,16 @@ namespace sqlpp { struct text_operand; +#if __cplusplus >= 201703L + using checked_type = std::string_view; +#else + using checked_type = std::string; +#endif + template struct wrap_operand< T, - typename std::enable_if::value and not is_result_field_t::value>::type> + typename std::enable_if::value and not is_result_field_t::value>::type> { using type = text_operand; };