relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
date_concepts.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../schema/column.hpp"
4
5#include <chrono>
6#include <optional>
7#include <type_traits>
8
11
13template <typename T>
15 using type = T;
16};
17
18template <typename T>
19struct remove_optional<std::optional<T>> {
20 using type = T;
21};
22
23template <typename T>
25
27template <typename T>
28struct is_time_point : std::false_type {};
29
30template <typename Clock, typename Duration>
31struct is_time_point<std::chrono::time_point<Clock, Duration>> : std::true_type {};
32
33template <typename T>
35
37template <typename T>
38concept DateTimeType =
39 is_time_point_v<remove_optional_t<std::remove_cvref_t<T>>> ||
40 std::same_as<remove_optional_t<std::remove_cvref_t<T>>,
41 std::chrono::system_clock::time_point> ||
42 std::same_as<remove_optional_t<std::remove_cvref_t<T>>,
43 std::chrono::time_point<std::chrono::system_clock>> ||
44 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::year_month_day> ||
45 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::year> ||
46 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::month> ||
47 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::day> ||
48 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::weekday> ||
49 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::year_month> ||
50 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::month_day> ||
51 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::duration<int64_t>> ||
52 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::milliseconds> ||
53 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::seconds> ||
54 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::minutes> ||
55 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::hours> ||
56 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::days> ||
57 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::weeks> ||
58 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::months> ||
59 std::same_as<remove_optional_t<std::remove_cvref_t<T>>, std::chrono::years>;
60
62template <typename T>
64 using type = T;
65};
66
67template <typename TableT, schema::fixed_string Name, typename ColumnT, typename... Modifiers>
68struct extract_column_type<schema::column<TableT, Name, ColumnT, Modifiers...>> {
69 using type = ColumnT;
70};
71
72template <typename T>
74
76template <typename T>
78
79} // namespace relx::query::date_checking
Represents a column in a database table.
Definition column.hpp:217
Check if type is a date/time type (unwrapping optional)
Check if a type is a date/time type.
Type checking concepts for date/time operations.
typename extract_column_type< T >::type extract_column_type_t
typename remove_optional< T >::type remove_optional_t
STL namespace.
Helper to extract column type for checking.
Helper to check if a type is a time_point of any clock.
Remove optional wrapper to get base type.
Compile-time string type that can be used as template non-type parameter in C++20.