Skip to content

Commit e41c35a

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 47c5d7c + f05b74b commit e41c35a

File tree

4 files changed

+50
-24
lines changed

4 files changed

+50
-24
lines changed

COMM-LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2012-2021 Eugene Zakharov and others
1+
Copyright (c) 2012-2023 Eugene Zakharov and others
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

dev/functional/cxx_compiler_quirks.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@
3939
(defined(__clang__) && (__clang_major__ >= 12) && (__cplusplus >= 202002L))
4040
#define SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
4141
#endif
42+
43+
// clang 10 chokes on concepts that don't depend on template parameters;
44+
// when it tries to instantiate an expression in a requires expression, which results in an error,
45+
// the compiler reports an error instead of dismissing the templated function.
46+
#if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && (defined(__clang__) && (__clang_major__ == 10))
47+
#define SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS
48+
#endif

dev/serializing_util.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#include <string>
77
#include <ostream>
88
#include <utility> // std::exchange, std::tuple_size
9-
#if __cplusplus >= 202002L && __cpp_lib_concepts
9+
#if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
1010
#include <string_view>
1111
#include <algorithm> // std::find
1212
#endif
1313

14-
#include "functional/cxx_universal.h"
14+
#include "functional/cxx_universal.h" // ::size_t
1515
#include "functional/cxx_type_traits_polyfill.h"
1616
#include "tuple_helper/tuple_iteration.h"
1717
#include "error_code.h"
@@ -29,9 +29,14 @@ namespace sqlite_orm {
2929
template<class T, class Ctx>
3030
std::string serialize_order_by(const T& t, const Ctx& context);
3131

32-
#if __cplusplus >= 202002L && \
33-
__cpp_lib_concepts // contiguous iterator ranges depend on contiguous_iterator, sized_sentinel_for in all major implementations
34-
inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) {
32+
#if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
33+
// optimized version when string_view's iterator range constructor is available
34+
template<class SFINAE = void>
35+
void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape)
36+
requires requires {
37+
std::string_view{str.cbegin(), str.cend()};
38+
}
39+
{
3540
for(std::string::const_iterator it = str.cbegin(), next; true; it = next + 1) {
3641
next = std::find(it, str.cend(), char2Escape);
3742
os << std::string_view{it, next};
@@ -42,7 +47,9 @@ namespace sqlite_orm {
4247
os << std::string(2, char2Escape);
4348
}
4449
}
45-
#else
50+
51+
template<class SFINAE = void>
52+
#endif
4653
inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) {
4754
if(str.find(char2Escape) == str.npos) {
4855
os << str;
@@ -55,7 +62,6 @@ namespace sqlite_orm {
5562
}
5663
}
5764
}
58-
#endif
5965

6066
inline void stream_identifier(std::ostream& ss,
6167
const std::string& qualifier,

include/sqlite_orm/sqlite_orm.h

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)