@@ -140,6 +140,13 @@ using std::nullptr_t;
140140#define SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
141141#endif
142142
143+ // clang 10 chokes on concepts that don't depend on template parameters;
144+ // when it tries to instantiate an expression in a requires expression, which results in an error,
145+ // the compiler reports an error instead of dismissing the templated function.
146+ #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && (defined(__clang__) && (__clang_major__ == 10))
147+ #define SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS
148+ #endif
149+
143150#if SQLITE_ORM_HAS_INCLUDE(<version>)
144151#include <version>
145152#endif
@@ -13191,13 +13198,13 @@ namespace sqlite_orm {
1319113198#include <string>
1319213199#include <ostream>
1319313200#include <utility> // std::exchange, std::tuple_size
13194- #if __cplusplus >= 202002L && __cpp_lib_concepts
13201+ #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
1319513202#include <string_view>
1319613203#include <algorithm> // std::find
1319713204#endif
1319813205
1319913206// #include "functional/cxx_universal.h"
13200-
13207+ // ::size_t
1320113208// #include "functional/cxx_type_traits_polyfill.h"
1320213209
1320313210// #include "tuple_helper/tuple_iteration.h"
@@ -13219,9 +13226,14 @@ namespace sqlite_orm {
1321913226 template<class T, class Ctx>
1322013227 std::string serialize_order_by(const T& t, const Ctx& context);
1322113228
13222- #if __cplusplus >= 202002L && \
13223- __cpp_lib_concepts // contiguous iterator ranges depend on contiguous_iterator, sized_sentinel_for in all major implementations
13224- inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) {
13229+ #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
13230+ // optimized version when string_view's iterator range constructor is available
13231+ template<class SFINAE = void>
13232+ void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape)
13233+ requires requires {
13234+ std::string_view{str.cbegin(), str.cend()};
13235+ }
13236+ {
1322513237 for(std::string::const_iterator it = str.cbegin(), next; true; it = next + 1) {
1322613238 next = std::find(it, str.cend(), char2Escape);
1322713239 os << std::string_view{it, next};
@@ -13232,20 +13244,21 @@ namespace sqlite_orm {
1323213244 os << std::string(2, char2Escape);
1323313245 }
1323413246 }
13235- #else
13236- inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) {
13237- if(str.find(char2Escape) == str.npos) {
13238- os << str;
13239- } else {
13240- for(char c: str) {
13241- if(c == char2Escape) {
13242- os << char2Escape;
13243- }
13244- os << c ;
13247+
13248+ template<class SFINAE = void>
13249+ #endif
13250+ inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) {
13251+ if(str.find(char2Escape) == str.npos) {
13252+ os << str;
13253+ } else {
13254+ for(char c: str) {
13255+ if(c == char2Escape) {
13256+ os << char2Escape ;
1324513257 }
13258+ os << c;
1324613259 }
1324713260 }
13248- #endif
13261+ }
1324913262
1325013263 inline void stream_identifier(std::ostream& ss,
1325113264 const std::string& qualifier,
0 commit comments