Skip to content

Commit 8742640

Browse files
authored
Merge pull request #1465 from fnc12/c++17-require-ctad
Require C++17 CTAD
2 parents 92b7959 + 8a5f824 commit 8742640

File tree

13 files changed

+32
-102
lines changed

13 files changed

+32
-102
lines changed

dev/functional/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define SQLITE_ORM_EXPORT
1212
#endif
1313

14-
#if SQLITE_ORM_HAS_INCLUDE(<version>)
14+
#if __has_include(<version>)
1515
#include <version>
1616
#endif
1717

dev/functional/cxx_check_prerequisites.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
// note: Before the C++17 language standard was made the baseline, the library had workarounds for these specific missing C++14 language features,
88
// so they are kept here as explicit checks for reference.
9-
#if __cpp_aggregate_nsdmi < 201304L || __cpp_constexpr < 201304L
9+
#if (__cpp_aggregate_nsdmi < 201304L || __cpp_constexpr < 201304L)
1010
#error A fully C++17-compliant compiler is required.
1111
#endif
1212

13-
#if (__cpp_noexcept_function_type < 201510L) || \
14-
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
15-
__cpp_range_based_for < 201603L) || \
16-
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L)
13+
#if (!defined(__has_include)) || \
14+
((__cpp_noexcept_function_type < 201510L) || \
15+
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
16+
__cpp_range_based_for < 201603L) || \
17+
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L) || \
18+
(__cpp_deduction_guides < 201703L))
1719
#error A fully C++17-compliant compiler is required.
1820
#endif

dev/functional/cxx_core_features.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@
1111
#define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) 0L
1212
#endif
1313

14-
#ifdef __has_include
15-
#define SQLITE_ORM_HAS_INCLUDE(file) __has_include(file)
16-
#else
17-
#define SQLITE_ORM_HAS_INCLUDE(file) 0L
18-
#endif
19-
20-
#if __cpp_deduction_guides >= 201703L
21-
#define SQLITE_ORM_CTAD_SUPPORTED
22-
#endif
23-
2414
#if __cpp_generic_lambdas >= 201707L
2515
#define SQLITE_ORM_EXPLICIT_GENERIC_LAMBDA_SUPPORTED
2616
#endif

dev/functional/cxx_optional.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
#ifdef SQLITE_ORM_IMPORT_STD_MODULE
66
#include <version>
7-
#else
8-
#if SQLITE_ORM_HAS_INCLUDE(<optional>)
7+
#elif __has_include(<optional>)
98
#include <optional>
109
#endif
11-
#endif
1210

1311
#if __cpp_lib_optional >= 201606L
1412
#define SQLITE_ORM_OPTIONAL_SUPPORTED

dev/functional/cxx_string_view.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
#ifdef SQLITE_ORM_IMPORT_STD_MODULE
66
#include <version>
7-
#else
8-
#if SQLITE_ORM_HAS_INCLUDE(<string_view>)
7+
#elif __has_include(<string_view>)
98
#include <string_view>
109
#endif
11-
#endif
1210

1311
#if __cpp_lib_string_view >= 201606L
1412
#define SQLITE_ORM_STRING_VIEW_SUPPORTED

dev/storage.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,15 @@ namespace sqlite_orm {
8888

8989
template<class Opt, class OptionsTpl>
9090
decltype(auto) storage_opt_or_default(OptionsTpl& options) {
91-
#ifdef SQLITE_ORM_CTAD_SUPPORTED
9291
if constexpr (tuple_has_type<OptionsTpl, Opt>::value) {
9392
return std::move(std::get<Opt>(options));
9493
} else {
9594
return Opt{};
9695
}
97-
#else
98-
return Opt{};
99-
#endif
10096
}
10197

10298
/**
103-
* Storage class itself. Create an instanse to use it as an interfacto to sqlite db by calling `make_storage`
99+
* Storage class itself. Create an instance to use it as an interfacto to sqlite db by calling `make_storage`
104100
* function.
105101
*/
106102
template<class... DBO>
@@ -1759,7 +1755,6 @@ namespace sqlite_orm {
17591755
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED
17601756
}; // struct storage_t
17611757

1762-
#ifdef SQLITE_ORM_CTAD_SUPPORTED
17631758
template<class Elements>
17641759
using dbo_index_sequence = filter_tuple_sequence_t<Elements, check_if_lacks<storage_opt_tag_t>::template fn>;
17651760

@@ -1770,12 +1765,10 @@ namespace sqlite_orm {
17701765
storage_t<DBO...> make_storage(std::string filename, std::tuple<DBO...> dbObjects, OptionsTpl options) {
17711766
return {std::move(filename), std::move(dbObjects), std::move(options)};
17721767
}
1773-
#endif
17741768
}
17751769
}
17761770

17771771
SQLITE_ORM_EXPORT namespace sqlite_orm {
1778-
#ifdef SQLITE_ORM_CTAD_SUPPORTED
17791772
/*
17801773
* Factory function for a storage instance, from a database file, a set of database object definitions
17811774
* and option storage options like connection control options and an 'on open' callback.
@@ -1793,15 +1786,6 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
17931786
create_from_tuple<std::tuple>(std::move(specTuple), dbo_index_sequence<decltype(specTuple)>{}),
17941787
create_from_tuple<std::tuple>(std::move(specTuple), opt_index_sequence<decltype(specTuple)>{}));
17951788
}
1796-
#else
1797-
/*
1798-
* Factory function for a storage instance, from a database file and a bunch of database object definitions.
1799-
*/
1800-
template<class... DBO>
1801-
internal::storage_t<DBO...> make_storage(std::string filename, DBO... dbObjects) {
1802-
return {std::move(filename), {std::forward<DBO>(dbObjects)...}, std::tuple<>{}};
1803-
}
1804-
#endif
18051789

18061790
/**
18071791
* sqlite3_threadsafe() interface.

dev/storage_options.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
5252
static_assert(std::is_aggregate_v<connection_control>);
5353
#endif
5454

55-
#ifdef SQLITE_ORM_CTAD_SUPPORTED
5655
/**
5756
* Callback function to be passed to `make_storage()`.
5857
* The provided function is called immdediately after the database connection has been established and set up.
5958
*/
6059
inline internal::on_open_spec on_open(std::function<void(sqlite3*)> onOpen) {
6160
return {std::move(onOpen)};
6261
}
63-
#endif
62+
6463
inline internal::will_run_query_spec
6564
will_run_query(std::function<void(internal::serialize_arg_type)> willRunQuery) {
6665
return {std::move(willRunQuery)};

dev/tuple_helper/tuple_transformer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ namespace sqlite_orm {
122122
}
123123
#endif
124124

125-
#ifdef SQLITE_ORM_CTAD_SUPPORTED
126125
template<template<typename...> class R, class Tpl, size_t... Idx, class Projection = polyfill::identity>
127126
constexpr auto create_from_tuple(Tpl&& tpl, std::index_sequence<Idx...>, Projection project = {}) {
128127
return R{polyfill::invoke(project, std::get<Idx>(std::forward<Tpl>(tpl)))...};
@@ -148,7 +147,6 @@ namespace sqlite_orm {
148147
std::make_index_sequence<std::tuple_size<std::remove_reference_t<Tpl>>::value>{},
149148
std::forward<Projection>(project));
150149
}
151-
#endif
152150
#endif
153151
}
154152
}

examples/any.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
* BLOB is mapped to std::vector<char>.
1515
*/
1616
#include <sqlite_orm/sqlite_orm.h>
17-
#ifdef __has_include
1817
#if __has_include(<any>)
1918
#include <any>
2019
#endif
21-
#endif
2220

2321
#if __cpp_lib_any >= 201606L
2422
#define ENABLE_THIS_EXAMPLE

examples/chrono_binding.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include <sqlite3.h>
22
#include <sqlite_orm/sqlite_orm.h>
3-
#ifdef __has_include
43
#if __has_include(<version>)
54
#include <version>
65
#endif
7-
#endif
86
#if __cpp_lib_chrono >= 201907L && __cpp_lib_format >= 201907L
97
#define ENABLE_THIS_EXAMPLE
108
#endif

0 commit comments

Comments
 (0)