Skip to content

Commit 8e8ef20

Browse files
authored
Merge pull request #1419 from fnc12/c++17-round-3
The following C++ language features are now a requirement: * Exception specifications as part of the type system. * Fold expressions. * constexpr lambda expressions. * Initialization of aggregate classes with base classes.
2 parents 546fa36 + fc3da95 commit 8e8ef20

23 files changed

+55
-295
lines changed

dev/constraints.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ namespace sqlite_orm {
5353
const primary_key_type& as_base() const {
5454
return *this;
5555
}
56-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
57-
constexpr primary_key_with_autoincrement(primary_key_type primary_key) : primary_key_type{primary_key} {}
58-
#endif
5956
};
6057

6158
/**

dev/functional/config.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
#include <version>
1313
#endif
1414

15-
#ifdef SQLITE_ORM_CONSTEXPR_LAMBDAS_SUPPORTED
16-
#define SQLITE_ORM_CONSTEXPR_LAMBDA_CPP17 constexpr
17-
#else
18-
#define SQLITE_ORM_CONSTEXPR_LAMBDA_CPP17
19-
#endif
20-
2115
#ifdef SQLITE_ORM_INLINE_VARIABLES_SUPPORTED
2216
#define SQLITE_ORM_INLINE_VAR inline
2317
#else
@@ -76,9 +70,7 @@
7670
#define SQLITE_ORM_WITH_CPP20_ALIASES
7771
#endif
7872

79-
#if defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)
8073
#define SQLITE_ORM_WITH_CTE
81-
#endif
8274

8375
// define the inline namespace "literals" so that it is available even if it was not introduced by a feature
8476
namespace sqlite_orm {

dev/functional/cxx_check_prerequisites.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#error A fully C++17-compliant compiler is required.
1111
#endif
1212

13-
#if __cpp_if_constexpr < 201606L
13+
#if (__cpp_noexcept_function_type < 201510L) || \
14+
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L) || \
15+
(__cpp_if_constexpr < 201606L)
1416
#error A fully C++17-compliant compiler is required.
1517
#endif

dev/functional/cxx_core_features.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,6 @@
1717
#define SQLITE_ORM_HAS_INCLUDE(file) 0L
1818
#endif
1919

20-
#if __cpp_noexcept_function_type >= 201510L
21-
#define SQLITE_ORM_NOTHROW_ALIASES_SUPPORTED
22-
#endif
23-
24-
#if __cpp_aggregate_bases >= 201603L
25-
#define SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
26-
#endif
27-
28-
#if __cpp_fold_expressions >= 201603L
29-
#define SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED
30-
#endif
31-
32-
#if __cpp_constexpr >= 201603L
33-
#define SQLITE_ORM_CONSTEXPR_LAMBDAS_SUPPORTED
34-
#endif
35-
3620
#if __cpp_range_based_for >= 201603L
3721
#define SQLITE_ORM_SENTINEL_BASED_FOR_SUPPORTED
3822
#endif

dev/functional/cxx_functional_polyfill.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace sqlite_orm {
8585
template<class Void, class... X>
8686
struct is_invocable_impl : std::false_type {};
8787

88-
#if __cplusplus >= 201703
88+
#if __cplusplus >= 201703L
8989
template<class... Ts>
9090
struct is_invocable_impl<polyfill::void_t<decltype(polyfill::invoke(std::declval<Ts>()...))>, Ts...>
9191
: std::true_type {};

dev/functional/function_traits.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ namespace sqlite_orm {
5151
using signature_type = R(Args...) const;
5252
};
5353

54-
#ifdef SQLITE_ORM_NOTHROW_ALIASES_SUPPORTED
5554
template<class R, class... Args>
5655
struct function_traits<R(Args...) noexcept> : function_traits<R(Args...)> {
5756
using signature_type = R(Args...) noexcept;
@@ -61,7 +60,6 @@ namespace sqlite_orm {
6160
struct function_traits<R(Args...) const noexcept> : function_traits<R(Args...)> {
6261
using signature_type = R(Args...) const noexcept;
6362
};
64-
#endif
6563

6664
/*
6765
* Pick signature of function pointer

dev/functional/index_sequence_util.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace sqlite_orm {
1414
SQLITE_ORM_CONSTEVAL auto index_sequence_value_at(std::index_sequence<Idx...>) {
1515
return Idx...[Pos];
1616
}
17-
#elif defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)
17+
#else
1818
/**
1919
* Get the index value of an `index_sequence` at a specific position.
2020
*/
@@ -31,16 +31,6 @@ namespace sqlite_orm {
3131
(void)((result = Idx, i++ == Pos) || ...);
3232
return result;
3333
}
34-
#else
35-
/**
36-
* Get the index value of an `index_sequence` at a specific position.
37-
* `Pos` must always be `0`.
38-
*/
39-
template<size_t Pos, size_t I, size_t... Idx>
40-
SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence<I, Idx...>) {
41-
static_assert(Pos == 0, "");
42-
return I;
43-
}
4434
#endif
4535

4636
template<class... Seq>

dev/member_traits/member_traits.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ namespace sqlite_orm {
3434
template<class F>
3535
struct getter_field_type<F(void)> : polyfill::remove_cvref<F> {};
3636

37-
#ifdef SQLITE_ORM_NOTHROW_ALIASES_SUPPORTED
3837
template<class F>
3938
struct getter_field_type<F(void) const noexcept> : polyfill::remove_cvref<F> {};
4039

4140
template<class F>
4241
struct getter_field_type<F(void) noexcept> : polyfill::remove_cvref<F> {};
43-
#endif
4442

4543
// SFINAE friendly trait to get a member function pointer's field type (i.e. unqualified parameter type)
4644
template<class T>
@@ -55,10 +53,8 @@ namespace sqlite_orm {
5553
template<class F>
5654
struct setter_field_type<void(F)> : polyfill::remove_cvref<F> {};
5755

58-
#ifdef SQLITE_ORM_NOTHROW_ALIASES_SUPPORTED
5956
template<class F>
6057
struct setter_field_type<void(F) noexcept> : polyfill::remove_cvref<F> {};
61-
#endif
6258

6359
template<class T, class SFINAE = void>
6460
struct is_getter : std::false_type {};

dev/schema/column.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,7 @@ namespace sqlite_orm {
9797
* It is a composition of orthogonal information stored in different base classes.
9898
*/
9999
template<class G, class S, class... Op>
100-
struct column_t : column_identifier, column_field<G, S>, column_constraints<Op...> {
101-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
102-
column_t(std::string name, G memberPointer, S setter, std::tuple<Op...> op) :
103-
column_identifier{std::move(name)}, column_field<G, S>{memberPointer, setter},
104-
column_constraints<Op...>{std::move(op)} {}
105-
#endif
106-
};
100+
struct column_t : column_identifier, column_field<G, S>, column_constraints<Op...> {};
107101

108102
template<class T, class SFINAE = void>
109103
struct column_field_expression {

dev/schema/index.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ namespace sqlite_orm {
2525
using object_type = void;
2626
using table_mapped_type = T;
2727

28-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
29-
index_t(std::string name_, bool unique_, elements_type elements_) :
30-
index_base{std::move(name_), unique_}, elements(std::move(elements_)) {}
31-
#endif
32-
3328
elements_type elements;
3429
};
3530
}

dev/schema/table.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ namespace sqlite_orm {
8787

8888
elements_type elements;
8989

90-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
91-
table_t(std::string name_, elements_type elements_) :
92-
basic_table{std::move(name_)}, elements{std::move(elements_)} {}
93-
#endif
94-
9590
table_t<O, true, Cs...> without_rowid() const {
9691
return {this->name, this->elements};
9792
}
@@ -311,11 +306,6 @@ namespace sqlite_orm {
311306

312307
module_details_type module_details;
313308

314-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
315-
virtual_table_t(std::string name, module_details_type module_details) :
316-
basic_table{std::move(name)}, module_details{std::move(module_details)} {}
317-
#endif
318-
319309
/**
320310
* Call passed lambda with columns not having the specified constraint trait `OpTrait`.
321311
* @param lambda Lambda called for each column.

dev/schema/triggers.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ namespace sqlite_orm {
7272
* Statements of the triggers (to be executed when the trigger fires)
7373
*/
7474
elements_type elements;
75-
76-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
77-
trigger_t(std::string name, T trigger_base, elements_type statements) :
78-
base_trigger{std::move(name)}, base(std::move(trigger_base)), elements(std::move(statements)) {}
79-
#endif
8075
};
8176

8277
/**

dev/statement_binder.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,10 @@ namespace sqlite_orm {
337337
}
338338

339339
private:
340-
#ifdef SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED
341340
template<class Tpl, size_t... Idx, class Projection>
342341
void operator()(const Tpl& tpl, std::index_sequence<Idx...>, Projection project) const {
343342
(this->bind(polyfill::invoke(project, std::get<Idx>(tpl)), Idx), ...);
344343
}
345-
#else
346-
template<class Tpl, size_t... Idx, class Projection>
347-
void operator()(const Tpl& tpl, std::index_sequence<Idx...>, Projection project) const {
348-
using Sink = int[sizeof...(Idx)];
349-
(void)Sink{(this->bind(polyfill::invoke(project, std::get<Idx>(tpl)), Idx), 0)...};
350-
}
351-
#endif
352344

353345
template<class T>
354346
void bind(const T& t, size_t idx) const {

dev/storage.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,8 @@ namespace sqlite_orm {
258258

259259
template<class O>
260260
void assert_updatable_type() const {
261-
#if defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)
262-
using Table = storage_pick_table_t<O, db_objects_type>;
263-
using elements_type = elements_type_t<Table>;
261+
using table_type = storage_pick_table_t<O, db_objects_type>;
262+
using elements_type = elements_type_t<table_type>;
264263
using col_index_sequence = filter_tuple_sequence_t<elements_type, is_column>;
265264
using pk_index_sequence = filter_tuple_sequence_t<elements_type, is_primary_key>;
266265
using pkcol_index_sequence = col_index_sequence_with<elements_type, is_primary_key>;
@@ -274,7 +273,6 @@ namespace sqlite_orm {
274273
static_assert(
275274
nonPrimaryKeysColumnsCount > 0,
276275
"A table with only primary keys cannot be updated. You need at least 1 non-primary key column");
277-
#endif
278276
}
279277

280278
template<class O,

dev/tuple_helper/tuple_iteration.h

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace sqlite_orm {
1010
namespace internal {
11-
#if defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)
1211
template<bool reversed = false, class Tpl, size_t... Idx, class L>
1312
constexpr void iterate_tuple(Tpl& tpl, std::index_sequence<Idx...>, L&& lambda) {
1413
if constexpr (reversed) {
@@ -24,50 +23,26 @@ namespace sqlite_orm {
2423
(lambda(std::get<Idx>(tpl)), ...);
2524
}
2625
}
27-
#else
28-
template<bool reversed = false, class Tpl, class L>
29-
void iterate_tuple(Tpl& /*tpl*/, std::index_sequence<>, L&& /*lambda*/) {}
3026

31-
template<bool reversed = false, class Tpl, size_t I, size_t... Idx, class L>
32-
void iterate_tuple(Tpl& tpl, std::index_sequence<I, Idx...>, L&& lambda) {
33-
if constexpr (reversed) {
34-
iterate_tuple<reversed>(tpl, std::index_sequence<Idx...>{}, std::forward<L>(lambda));
35-
lambda(std::get<I>(tpl));
36-
} else {
37-
lambda(std::get<I>(tpl));
38-
iterate_tuple<reversed>(tpl, std::index_sequence<Idx...>{}, std::forward<L>(lambda));
39-
}
40-
}
41-
#endif
4227
template<bool reversed = false, class Tpl, class L>
4328
constexpr void iterate_tuple(Tpl&& tpl, L&& lambda) {
4429
iterate_tuple<reversed>(tpl,
4530
std::make_index_sequence<std::tuple_size<std::remove_reference_t<Tpl>>::value>{},
4631
std::forward<L>(lambda));
4732
}
4833

49-
#ifdef SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED
5034
template<class Tpl, size_t... Idx, class L>
5135
constexpr void iterate_tuple(std::index_sequence<Idx...>, L&& lambda) {
5236
(lambda((std::tuple_element_t<Idx, Tpl>*)nullptr), ...);
5337
}
54-
#else
55-
template<class Tpl, size_t... Idx, class L>
56-
constexpr void iterate_tuple(std::index_sequence<Idx...>, L&& lambda) {
57-
using Sink = int[sizeof...(Idx)];
58-
(void)Sink{(lambda((std::tuple_element_t<Idx, Tpl>*)nullptr), 0)...};
59-
}
60-
#endif
38+
6139
template<class Tpl, class L>
6240
constexpr void iterate_tuple(L&& lambda) {
6341
iterate_tuple<Tpl>(std::make_index_sequence<std::tuple_size<Tpl>::value>{}, std::forward<L>(lambda));
6442
}
6543

6644
template<template<class...> class Base, class L>
6745
struct lambda_as_template_base : L {
68-
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
69-
lambda_as_template_base(L&& lambda) : L{std::move(lambda)} {}
70-
#endif
7146
template<class... T>
7247
decltype(auto) operator()(const Base<T...>& object) {
7348
return L::operator()(object);

dev/tuple_helper/tuple_transformer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace sqlite_orm {
2828
template<class Pack, template<class...> class Op>
2929
using transform_tuple_t = typename tuple_transformer<Pack, Op>::type;
3030

31-
// note: applying a combiner like `plus_fold_integrals` needs fold expressions
32-
#if defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)
3331
/*
3432
* Apply a projection to a tuple's elements filtered by the specified indexes, and combine the results.
3533
*
@@ -95,7 +93,6 @@ namespace sqlite_orm {
9593
IdxSeq{},
9694
project_nested_tuple_size<NestedProject>{},
9795
std::integral_constant<size_t, 0u>{}));
98-
#endif
9996

10097
template<class R, class Tpl, size_t... Idx, class Projection = polyfill::identity>
10198
constexpr R create_from_tuple(Tpl&& tpl, std::index_sequence<Idx...>, Projection project = {}) {

dev/udf_proxy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace sqlite_orm {
2424
std::allocator<UDF> allocator;
2525
using traits = std::allocator_traits<decltype(allocator)>;
2626

27-
SQLITE_ORM_CONSTEXPR_LAMBDA_CPP17 auto deallocate = [](void* location) noexcept {
27+
constexpr auto deallocate = [](void* location) noexcept {
2828
std::allocator<UDF> allocator;
2929
using traits = std::allocator_traits<decltype(allocator)>;
3030
traits::deallocate(allocator, (UDF*)location, 1);
@@ -38,13 +38,13 @@ namespace sqlite_orm {
3838
*/
3939
template<class UDF>
4040
std::pair<void* (*)(), xdestroy_fn_t> obtain_udf_allocator() {
41-
SQLITE_ORM_CONSTEXPR_LAMBDA_CPP17 auto allocate = []() {
41+
constexpr auto allocate = []() {
4242
std::allocator<UDF> allocator;
4343
using traits = std::allocator_traits<decltype(allocator)>;
4444
return (void*)traits::allocate(allocator, 1);
4545
};
4646

47-
SQLITE_ORM_CONSTEXPR_LAMBDA_CPP17 auto deallocate = [](void* location) noexcept {
47+
constexpr auto deallocate = [](void* location) noexcept {
4848
std::allocator<UDF> allocator;
4949
using traits = std::allocator_traits<decltype(allocator)>;
5050
traits::deallocate(allocator, (UDF*)location, 1);

0 commit comments

Comments
 (0)