11#pragma once
22
33#ifndef SQLITE_ORM_IMPORT_STD_MODULE
4- #include < type_traits> // std::is_base_of, std::is_same
5- #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
4+ #include < type_traits> // std::is_base_of, std::is_same, std::remove_const
5+ #ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED
66#include < concepts>
77#endif
88#endif
99
1010#include " functional/cxx_type_traits_polyfill.h"
1111#include " type_traits.h"
12- #include " table_reference.h"
1312
1413SQLITE_ORM_EXPORT namespace sqlite_orm {
1514
@@ -20,6 +19,22 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
2019
2120namespace sqlite_orm {
2221 namespace internal {
22+ template <class O >
23+ struct table_reference ;
24+
25+ template <class RecordSet >
26+ struct decay_table_ref : std::remove_const<RecordSet> {};
27+ template <class O >
28+ struct decay_table_ref <table_reference<O>> : polyfill::type_identity<O> {};
29+ template <class O >
30+ struct decay_table_ref <const table_reference<O>> : polyfill::type_identity<O> {};
31+
32+ template <class RecordSet >
33+ using decay_table_ref_t = typename decay_table_ref<RecordSet>::type;
34+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
35+ template <auto recordset>
36+ using auto_decay_table_ref_t = typename decay_table_ref<decltype (recordset)>::type;
37+ #endif
2338
2439 template <class A >
2540 inline constexpr bool is_alias_v = std::is_base_of<alias_tag, A>::value;
@@ -36,6 +51,13 @@ namespace sqlite_orm {
3651 template <class A >
3752 struct is_column_alias : is_alias<A> {};
3853
54+ template <class O >
55+ inline constexpr bool is_table_reference_v =
56+ polyfill::is_specialization_of_v<std::remove_const_t <O>, table_reference>;
57+
58+ template <class R >
59+ struct is_table_reference : polyfill::bool_constant<is_table_reference_v<R>> {};
60+
3961 /* * @short Alias of any type of record set, see `orm_recordset_alias`.
4062 */
4163 template <class A >
@@ -68,11 +90,20 @@ namespace sqlite_orm {
6890
6991 template <class A >
7092 using is_cte_moniker = polyfill::bool_constant<is_cte_moniker_v<A>>;
93+
94+ /* * @short Referring to a recordset.
95+ */
96+ template <class T >
97+ inline constexpr bool is_referring_to_recordset_v =
98+ polyfill::disjunction_v<is_table_reference<T>, is_recordset_alias<T>>;
99+
100+ template <class T >
101+ using is_referring_to_recordset = polyfill::bool_constant<is_referring_to_recordset_v<T>>;
71102 }
72103}
73104
74105SQLITE_ORM_EXPORT namespace sqlite_orm {
75- #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
106+ #ifdef SQLITE_ORM_CPP20_CONCEPTS_SUPPORTED
76107 template <class A >
77108 concept orm_alias = std::derived_from<A, alias_tag>;
78109
@@ -85,6 +116,14 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
85116 template <class A >
86117 concept orm_column_alias = (orm_alias<A> && !orm_names_type<A>);
87118
119+ /* * @short Specifies that a type is a reference of a concrete table, especially of a derived class.
120+ *
121+ * A concrete table reference has the following traits:
122+ * - specialization of `table_reference`, whose `type` typename references a mapped object.
123+ */
124+ template <class O >
125+ concept orm_table_reference = polyfill::is_specialization_of_v<std::remove_const_t <O>, internal::table_reference>;
126+
88127 /* * @short Specifies that a type is an alias of any type of record set.
89128 *
90129 * A record set alias has the following traits:
0 commit comments