Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Moved central C++ features to universal header file
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed May 11, 2022
1 parent 4db1414 commit e3e853e
Show file tree
Hide file tree
Showing 47 changed files with 219 additions and 179 deletions.
2 changes: 1 addition & 1 deletion dev/ast/group_by.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <type_traits> // std::true_type, std::false_type
#include <utility> // std::forward, std::move

#include "../cxx_polyfill.h"
#include "../functional/cxx_polyfill.h"

namespace sqlite_orm {
namespace internal {
Expand Down
4 changes: 1 addition & 3 deletions dev/ast/into.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include <type_traits> // std::true_type, std::false_type

#include "../cxx_polyfill.h"
#include "../functional/cxx_polyfill.h"

namespace sqlite_orm {
namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion dev/ast/upsert_clause.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <type_traits> // std::false_type, std::true_type
#include <utility> // std::forward, std::move

#include "../cxx_polyfill.h"
#include "../functional/cxx_polyfill.h"

namespace sqlite_orm {
namespace internal {
Expand Down
4 changes: 2 additions & 2 deletions dev/ast/where.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <type_traits> // std::false_type, std::true_type
#include <utility> // std::move

#include "../start_macros.h"
#include "../cxx_polyfill.h"
#include "../functional/cxx_universal.h"
#include "../functional/cxx_polyfill.h"
#include "../serialize_result_type.h"

namespace sqlite_orm {
Expand Down
2 changes: 1 addition & 1 deletion dev/carray.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <type_traits> // std::integral_constant
#include <utility> // std::move

#include "start_macros.h"
#include "functional/cxx_universal.h"
#include "pointer_value.h"

namespace sqlite_orm {
Expand Down
4 changes: 2 additions & 2 deletions dev/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <memory> // std::unique_ptr
#include <type_traits> // std::true_type, std::false_type, std::is_same, std::enable_if, std::decay

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "type_traits.h"
#include "type_is_nullable.h"
#include "tuple_helper/tuple_helper.h"
Expand Down
5 changes: 3 additions & 2 deletions dev/column_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <tuple> // std::tuple
#include <functional> // std::reference_wrapper

#include "functional/cxx_universal.h"
#include "type_traits.h"
#include "member_traits/member_traits.h"
#include "core_functions.h"
Expand Down Expand Up @@ -90,8 +91,8 @@ namespace sqlite_orm {
};

template<class St>
struct column_result_t<St, std::nullptr_t, void> {
using type = std::nullptr_t;
struct column_result_t<St, nullptr_t, void> {
using type = nullptr_t;
};

template<class St>
Expand Down
4 changes: 2 additions & 2 deletions dev/conditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <tuple> // std::tuple, std::tuple_size
#include <sstream> // std::stringstream

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "type_traits.h"
#include "collate_argument.h"
#include "constraints.h"
Expand Down
4 changes: 2 additions & 2 deletions dev/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <tuple> // std::tuple, std::make_tuple
#include <type_traits> // std::is_base_of, std::false_type, std::true_type

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "collate_argument.h"
#include "error_code.h"
#include "table_type.h"
Expand Down
2 changes: 1 addition & 1 deletion dev/core_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <memory> // std::unique_ptr
#include <vector> // std::vector

#include "cxx_polyfill.h"
#include "functional/cxx_polyfill.h"
#include "conditions.h"
#include "is_base_of_template.h"
#include "tuple_helper/tuple_filter.h"
Expand Down
11 changes: 10 additions & 1 deletion dev/expression.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#pragma once

#include <tuple>
#include <utility> // std::move, std::forward
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional>
#endif

#include "functional/cxx_universal.h"
#include "operators.h"

namespace sqlite_orm {
Expand All @@ -24,7 +33,7 @@ namespace sqlite_orm {
return {this->value, std::move(r)};
}

assign_t<T, std::nullptr_t> operator=(std::nullptr_t) const {
assign_t<T, nullptr_t> operator=(nullptr_t) const {
return {this->value, nullptr};
}
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
Expand Down
11 changes: 5 additions & 6 deletions dev/field_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <string> // std::string
#include <sstream> // std::stringstream
#include <vector> // std::vector
#include <cstddef> // std::nullptr_t
#include <memory> // std::shared_ptr, std::unique_ptr
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
#include <optional> // std::optional
Expand All @@ -13,8 +12,8 @@
#include <codecvt> // std::codecvt_utf8_utf16
#endif // SQLITE_ORM_OMITS_CODECVT

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "is_std_ptr.h"

namespace sqlite_orm {
Expand Down Expand Up @@ -113,8 +112,8 @@ namespace sqlite_orm {
};
#endif // SQLITE_ORM_OMITS_CODECVT
template<>
struct field_printer<std::nullptr_t, void> {
std::string operator()(const std::nullptr_t&) const {
struct field_printer<nullptr_t, void> {
std::string operator()(const nullptr_t&) const {
return "null";
}
};
Expand All @@ -137,7 +136,7 @@ namespace sqlite_orm {
if(t) {
return field_printer<unqualified_type>()(*t);
} else {
return field_printer<std::nullptr_t>{}(nullptr);
return field_printer<nullptr_t>{}(nullptr);
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions dev/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include <tuple> // std::tuple
#include <functional> // std::function
#include <algorithm> // std::min
#include <cstddef>
#include <utility> // std::move, std::forward

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"

namespace sqlite_orm {

Expand Down Expand Up @@ -159,7 +159,7 @@ namespace sqlite_orm {

// Always allow binding nullptr to a pointer argument
template<size_t I, class PointerArg>
constexpr bool is_same_pvt_v<I, PointerArg, std::nullptr_t, polyfill::void_t<typename PointerArg::tag>> = true;
constexpr bool is_same_pvt_v<I, PointerArg, nullptr_t, polyfill::void_t<typename PointerArg::tag>> = true;

#if __cplusplus >= 201703L // using C++17 or higher
template<size_t I, const char *PointerArg, const char *Binding>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dev/cxx_polyfill.h → dev/functional/cxx_polyfill.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <type_traits>

#include "start_macros.h"
#include "functional/cxx_universal.h"

namespace sqlite_orm {
namespace internal {
Expand Down
20 changes: 20 additions & 0 deletions dev/functional/cxx_universal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

/*
* This header makes central C++ functionality on which sqlite_orm depends universally available:
* - alternative operator representations
* - ::size_t, ::ptrdiff_t, ::nullptr_t
* - C++ core feature macros
* - macros for dealing with compiler quirks
*/

#include <iso646.h> // alternative operator representations
#include <cstddef> // sqlite_orm is using size_t, ptrdiff_t, nullptr_t everywhere, pull it in early

// earlier clang versions didn't make nullptr_t available in the global namespace via stddef.h,
// though it should have according to C++ documentation (see https://en.cppreference.com/w/cpp/types/nullptr_t#Notes).
// actually it should be available when including stddef.h
using std::nullptr_t;

#include "cxx_core_features.h"
#include "cxx_compiler_quirks.h"
2 changes: 1 addition & 1 deletion dev/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string> // std::string
#include <utility> // std::forward

#include "start_macros.h"
#include "functional/cxx_universal.h"
#include "tuple_helper/tuple_filter.h"
#include "indexed_column.h"

Expand Down
2 changes: 1 addition & 1 deletion dev/indexed_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string> // std::string
#include <utility> // std::move

#include "start_macros.h"
#include "functional/cxx_universal.h"
#include "ast/where.h"

namespace sqlite_orm {
Expand Down
4 changes: 2 additions & 2 deletions dev/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <memory> // std::shared_ptr, std::unique_ptr, std::make_shared
#include <type_traits> // std::decay
#include <utility> // std::move
#include <cstddef> // std::ptrdiff_t
#include <iterator> // std::input_iterator_tag
#include <system_error> // std::system_error

#include "functional/cxx_universal.h"
#include "row_extractor.h"
#include "statement_finalizer.h"
#include "error_code.h"
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace sqlite_orm {
}

public:
using difference_type = std::ptrdiff_t;
using difference_type = ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::input_iterator_tag;
Expand Down
4 changes: 2 additions & 2 deletions dev/member_traits/member_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <type_traits> // std::enable_if, std::is_function, std::true_type, std::false_type

#include "../start_macros.h"
#include "../cxx_polyfill.h"
#include "../functional/cxx_universal.h"
#include "../functional/cxx_polyfill.h"

namespace sqlite_orm {
namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion dev/pointer_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <memory>
#include <utility>

#include "start_macros.h"
#include "functional/cxx_universal.h"
#include "xdestroy_handling.h"

namespace sqlite_orm {
Expand Down
4 changes: 2 additions & 2 deletions dev/prepared_statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <type_traits> // std::true_type, std::false_type
#include <utility> // std::pair

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "tuple_helper/tuple_filter.h"
#include "connection_holder.h"
#include "select_constraints.h"
Expand Down
9 changes: 5 additions & 4 deletions dev/row_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <iterator> // std::back_inserter
#include <tuple> // std::tuple, std::tuple_size, std::tuple_element

#include "functional/cxx_universal.h"
#include "arithmetic_tag.h"
#include "pointer_value.h"
#include "journal_mode.h"
Expand Down Expand Up @@ -256,16 +257,16 @@ namespace sqlite_orm {
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED

template<>
struct row_extractor<std::nullptr_t> {
std::nullptr_t extract(const char* /*row_value*/) const {
struct row_extractor<nullptr_t> {
nullptr_t extract(const char* /*row_value*/) const {
return nullptr;
}

std::nullptr_t extract(sqlite3_stmt* /*stmt*/, int /*columnIndex*/) const {
nullptr_t extract(sqlite3_stmt* /*stmt*/, int /*columnIndex*/) const {
return nullptr;
}

std::nullptr_t extract(sqlite3_value* /*value*/) const {
nullptr_t extract(sqlite3_value* /*value*/) const {
return nullptr;
}
};
Expand Down
5 changes: 2 additions & 3 deletions dev/row_extractor_builder.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <cstddef> // std::nullptr_t

#include "functional/cxx_universal.h"
#include "row_extractor.h"
#include "mapped_row_extractor.h"

Expand All @@ -10,7 +9,7 @@ namespace sqlite_orm {
namespace internal {

template<class T>
row_extractor<T> make_row_extractor(std::nullptr_t) {
row_extractor<T> make_row_extractor(nullptr_t) {
return {};
}

Expand Down
4 changes: 2 additions & 2 deletions dev/select_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <optional> // std::optional
#endif // SQLITE_ORM_OPTIONAL_SUPPORTED

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "is_base_of_template.h"
#include "tuple_helper/tuple_filter.h"
#include "optional_container.h"
Expand Down
4 changes: 2 additions & 2 deletions dev/serializing_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <algorithm> // std::find
#endif

#include "start_macros.h"
#include "cxx_polyfill.h"
#include "functional/cxx_universal.h"
#include "functional/cxx_polyfill.h"
#include "error_code.h"
#include "serializer_context.h"
#include "util.h"
Expand Down
6 changes: 0 additions & 6 deletions dev/start_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ __pragma(push_macro("min"))
__pragma(push_macro("max"))
#undef max
#endif // defined(_MSC_VER)

#include <iso646.h> // alternative operator representations
#include <stddef.h> // sqlite_orm is using size_t, ptrdiff_t everywhere, pull it in early

#include "cxx_core_features.h"
#include "cxx_compiler_quirks.h"
Loading

0 comments on commit e3e853e

Please sign in to comment.