-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
28 lines (24 loc) · 865 Bytes
/
Copy pathtest.cpp
File metadata and controls
28 lines (24 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <chrono>
#include <optional>
template <typename T>
class C;
int main() {
std::optional<std::chrono::system_clock::time_point> opt;
std::chrono::nanoseconds ns(12345678);
auto now = std::chrono::system_clock::now();
std::time_t tnow = std::chrono::system_clock::to_time_t(now);
std::tm* date = std::localtime(&tnow);
date->tm_hour = 0;
date->tm_min = 0;
date->tm_sec = 0;
auto midnight = std::chrono::system_clock::from_time_t(std::mktime(date));
C<decltype(midnight)>();
C<decltype(midnight + ns)>();
//static_assert(std::is_same_v<
// std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long long, std::ratio<1, 1000000000>>>,
// std::chrono::system_clock::time_point
// >);
opt.emplace(midnight + ns);
/// Hahaha!
}