Skip to content

Commit 5415cc8

Browse files
authored
Merge pull request #1260 from FireDaemon/streamlined_tuple_algos
Streamlined tuple "meta" algorithms
2 parents d1f39ad + 4db6c97 commit 5415cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1365
-846
lines changed

dev/alias.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ namespace sqlite_orm {
4747

4848
template<class T>
4949
SQLITE_ORM_INLINE_VAR constexpr bool
50-
is_operator_argument_v<T, std::enable_if_t<polyfill::is_specialization_of_v<T, alias_column_t>>> = true;
50+
is_operator_argument_v<T, std::enable_if_t<polyfill::is_specialization_of<T, alias_column_t>::value>> =
51+
true;
5152

5253
struct basic_table;
5354

@@ -134,7 +135,7 @@ namespace sqlite_orm {
134135

135136
template<class T>
136137
SQLITE_ORM_INLINE_VAR constexpr bool
137-
is_operator_argument_v<T, std::enable_if_t<polyfill::is_specialization_of_v<T, alias_holder>>> = true;
138+
is_operator_argument_v<T, std::enable_if_t<polyfill::is_specialization_of<T, alias_holder>::value>> = true;
138139

139140
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
140141
template<char A, char... X>
@@ -154,7 +155,7 @@ namespace sqlite_orm {
154155
* using als = alias_u<User>;
155156
* select(alias_column<als>(column<User>(&User::id)))
156157
*/
157-
template<class A, class C, std::enable_if_t<internal::is_table_alias_v<A>, bool> = true>
158+
template<class A, class C, std::enable_if_t<internal::is_table_alias<A>::value, bool> = true>
158159
constexpr auto alias_column(C field) {
159160
using namespace ::sqlite_orm::internal;
160161
using aliased_type = type_t<A>;
@@ -172,7 +173,7 @@ namespace sqlite_orm {
172173
* using als = alias_u<User>;
173174
* select(alias_column<als>(&User::id))
174175
*/
175-
template<class A, class F, class O, std::enable_if_t<internal::is_table_alias_v<A>, bool> = true>
176+
template<class A, class F, class O, std::enable_if_t<internal::is_table_alias<A>::value, bool> = true>
176177
constexpr auto alias_column(F O::*field) {
177178
using namespace ::sqlite_orm::internal;
178179
using aliased_type = type_t<A>;

dev/alias_traits.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ namespace sqlite_orm {
2121
SQLITE_ORM_INLINE_VAR constexpr bool is_alias_v = std::is_base_of<alias_tag, A>::value;
2222

2323
template<class A>
24-
using is_alias = polyfill::bool_constant<is_alias_v<A>>;
24+
struct is_alias : polyfill::bool_constant<is_alias_v<A>> {};
2525

2626
/** @short Alias of a column in a record set, see `orm_column_alias`.
2727
*/
2828
template<class A>
2929
SQLITE_ORM_INLINE_VAR constexpr bool is_column_alias_v =
30-
polyfill::conjunction_v<is_alias<A>, polyfill::negation<polyfill::is_detected<type_t, A>>>;
30+
polyfill::conjunction<is_alias<A>, polyfill::negation<polyfill::is_detected<type_t, A>>>::value;
3131

3232
template<class A>
33-
using is_column_alias = is_alias<A>;
33+
struct is_column_alias : is_alias<A> {};
3434

3535
/** @short Alias of any type of record set, see `orm_recordset_alias`.
3636
*/
3737
template<class A>
3838
SQLITE_ORM_INLINE_VAR constexpr bool is_recordset_alias_v =
39-
polyfill::conjunction_v<is_alias<A>, polyfill::is_detected<type_t, A>>;
39+
polyfill::conjunction<is_alias<A>, polyfill::is_detected<type_t, A>>::value;
4040

4141
template<class A>
42-
using is_recordset_alias = polyfill::bool_constant<is_recordset_alias_v<A>>;
42+
struct is_recordset_alias : polyfill::bool_constant<is_recordset_alias_v<A>> {};
4343

4444
/** @short Alias of a concrete table, see `orm_table_alias`.
4545
*/
@@ -49,7 +49,7 @@ namespace sqlite_orm {
4949
polyfill::negation<std::is_same<polyfill::detected_t<type_t, A>, std::remove_const_t<A>>>>;
5050

5151
template<class A>
52-
using is_table_alias = polyfill::bool_constant<is_table_alias_v<A>>;
52+
struct is_table_alias : polyfill::bool_constant<is_table_alias_v<A>> {};
5353

5454
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
5555
/*

dev/ast/set.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <sstream> // std::stringstream
77
#include <type_traits> // std::false_type, std::true_type
88

9+
#include "../tuple_helper/tuple_traits.h"
910
#include "../table_name_collector.h"
1011

1112
namespace sqlite_orm {

dev/ast/where.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace sqlite_orm {
3131
};
3232

3333
template<class T>
34-
SQLITE_ORM_INLINE_VAR constexpr bool is_where_v = polyfill::is_specialization_of_v<T, where_t>;
34+
SQLITE_ORM_INLINE_VAR constexpr bool is_where_v = polyfill::is_specialization_of<T, where_t>::value;
3535

3636
template<class T>
37-
using is_where = polyfill::bool_constant<is_where_v<T>>;
37+
struct is_where : polyfill::bool_constant<is_where_v<T>> {};
3838
}
3939

4040
/**

dev/ast_iterator.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ namespace sqlite_orm {
150150
};
151151

152152
template<class T>
153-
struct ast_iterator<T,
154-
std::enable_if_t<polyfill::disjunction_v<is_binary_condition<T>, is_binary_operator<T>>>> {
153+
struct ast_iterator<
154+
T,
155+
std::enable_if_t<polyfill::disjunction<is_binary_condition<T>, is_binary_operator<T>>::value>> {
155156
using node_type = T;
156157

157158
template<class L>
@@ -533,7 +534,7 @@ namespace sqlite_orm {
533534
// note: not strictly necessary as there's no binding support for USING;
534535
// we provide it nevertheless, in line with on_t.
535536
template<class T>
536-
struct ast_iterator<T, std::enable_if_t<polyfill::is_specialization_of_v<T, using_t>>> {
537+
struct ast_iterator<T, std::enable_if_t<polyfill::is_specialization_of<T, using_t>::value>> {
537538
using node_type = T;
538539

539540
template<class L>
@@ -662,9 +663,9 @@ namespace sqlite_orm {
662663
*/
663664
template<class T>
664665
struct ast_iterator<T,
665-
std::enable_if_t<polyfill::disjunction_v<polyfill::is_specialization_of<T, alias_holder>,
666-
polyfill::is_specialization_of<T, literal_holder>,
667-
is_column_alias<T>>>> {
666+
std::enable_if_t<polyfill::disjunction<polyfill::is_specialization_of<T, alias_holder>,
667+
polyfill::is_specialization_of<T, literal_holder>,
668+
is_column_alias<T>>::value>> {
668669
using node_type = T;
669670

670671
template<class L>

dev/column_names_getter.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace sqlite_orm {
3434
table.for_each_column([qualified = !context.skip_table_name,
3535
&tableName = table.name,
3636
&collectedExpressions](const column_identifier& column) {
37-
if(is_alias_v<T>) {
37+
if(is_alias<T>::value) {
3838
collectedExpressions.push_back(quote_identifier(alias_extractor<T>::extract()) + "." +
3939
quote_identifier(column.name));
4040
} else if(qualified) {
@@ -46,7 +46,7 @@ namespace sqlite_orm {
4646
});
4747
} else {
4848
collectedExpressions.reserve(collectedExpressions.size() + 1);
49-
if(is_alias_v<T>) {
49+
if(is_alias<T>::value) {
5050
collectedExpressions.push_back(quote_identifier(alias_extractor<T>::extract()) + ".*");
5151
} else if(!context.skip_table_name) {
5252
const basic_table& table = pick_table<mapped_type_proxy_t<T>>(context.db_objects);
@@ -98,8 +98,7 @@ namespace sqlite_orm {
9898
(*this)(colExpr, context);
9999
});
100100
// note: `capacity() > size()` can occur in case `asterisk_t<>` does spell out the columns in defined order
101-
if(mpl::invoke_t<check_if_tuple_has_template<asterisk_t>,
102-
typename columns_t<Args...>::columns_type>::value &&
101+
if(tuple_has_template<typename columns_t<Args...>::columns_type, asterisk_t>::value &&
103102
this->collectedExpressions.capacity() > this->collectedExpressions.size()) {
104103
this->collectedExpressions.shrink_to_fit();
105104
}

dev/column_pointer.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ namespace sqlite_orm {
2222
};
2323

2424
template<class T>
25-
SQLITE_ORM_INLINE_VAR constexpr bool is_column_pointer_v = polyfill::is_specialization_of_v<T, column_pointer>;
25+
SQLITE_ORM_INLINE_VAR constexpr bool is_column_pointer_v =
26+
polyfill::is_specialization_of<T, column_pointer>::value;
2627

2728
template<class T>
28-
using is_column_pointer = polyfill::bool_constant<is_column_pointer_v<T>>;
29+
struct is_column_pointer : polyfill::bool_constant<is_column_pointer_v<T>> {};
2930

3031
template<class T>
31-
SQLITE_ORM_INLINE_VAR constexpr bool is_operator_argument_v<T, std::enable_if_t<is_column_pointer_v<T>>> = true;
32+
SQLITE_ORM_INLINE_VAR constexpr bool is_operator_argument_v<T, std::enable_if_t<is_column_pointer<T>::value>> =
33+
true;
3234
}
3335

3436
/**

0 commit comments

Comments
 (0)