VCCC  2024.05
VisualCamp Common C++ library
time.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/12/08.
3 # */
4 #
5 # ifndef VCCC_UTILITY_TIME_HPP
6 # define VCCC_UTILITY_TIME_HPP
7 #
8 # include <chrono>
9 
10 namespace vccc {
11 
14 
15 template<typename T>
16 auto
18 {
19  auto now = std::chrono::system_clock::now();
20  auto duration = now.time_since_epoch();
21  return std::chrono::duration_cast<T>(duration).count();
22 }
23 
24 inline
25 decltype(auto)
27 {
28  return getCurrentTime<std::chrono::milliseconds>();
29 }
30 
31 inline
32 decltype(auto)
34 {
35  return getCurrentTime<std::chrono::microseconds>();
36 }
37 
38 inline
39 decltype(auto)
41 {
42  return getCurrentTime<std::chrono::nanoseconds>();
43 }
44 
46 
47 } // namespace vccc
48 
49 # endif // VCCC_UTILITY_TIME_HPP
decltype(auto) getCurrentMilliseconds()
Definition: time.hpp:26
auto getCurrentTime()
Definition: time.hpp:17
decltype(auto) getCurrentMicroseconds()
Definition: time.hpp:33
decltype(auto) getCurrentNanoseconds()
Definition: time.hpp:40
Definition: directory.h:12