cplusplus
.com
教程
參考
文章
論壇
C++
教程
參考
文章
論壇
參考
C 庫
<cassert> (assert.h)
<cctype> (ctype.h)
<cerrno> (errno.h)
C++11
<cfenv> (fenv.h)
<cfloat> (float.h)
C++11
<cinttypes> (inttypes.h)
<ciso646> (iso646.h)
<climits> (limits.h)
<clocale> (locale.h)
<cmath> (math.h)
<csetjmp> (setjmp.h)
<csignal> (signal.h)
<cstdarg> (stdarg.h)
C++11
<cstdbool> (stdbool.h)
<cstddef> (stddef.h)
C++11
<cstdint> (stdint.h)
<cstdio> (stdio.h)
<cstdlib> (stdlib.h)
<cstring> (string.h)
C++11
<ctgmath> (tgmath.h)
<ctime> (time.h)
C++11
<cuchar> (uchar.h)
<cwchar> (wchar.h)
<cwctype> (wctype.h)
容器
C++11
<array>
<deque>
C++11
<forward_list>
<list>
<map>
<queue>
<set>
<stack>
C++11
<unordered_map>
C++11
<unordered_set>
<vector>
輸入/輸出
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>
多執行緒
C++11
<atomic>
C++11
<condition_variable>
C++11
<future>
C++11
<mutex>
C++11
<thread>
其他
<algorithm>
<bitset>
C++11
<chrono>
C++11
<codecvt>
<complex>
<exception>
<functional>
C++11
<initializer_list>
<iterator>
<limits>
<locale>
<memory>
<new>
<numeric>
C++11
<random>
C++11
<ratio>
C++11
<regex>
<stdexcept>
<string>
C++11
<system_error>
C++11
<tuple>
C++11
<type_traits>
C++11
<typeindex>
<typeinfo>
<utility>
<valarray>
<chrono>
類
C++11
common_type (duration)
C++11
common_type (time_point)
C++11
duration
C++11
duration_values
C++11
high_resolution_clock
C++11
steady_clock
C++11
system_clock
C++11
time_point
C++11
treat_as_floating_point
函式
C++11
duration_cast
C++11
time_point_cast
類 typedef
C++11
hours
C++11
microseconds
C++11
milliseconds
C++11
minutes
C++11
nanoseconds
C++11
seconds
參考
<chrono>
標頭檔案
<chrono>
時間庫
chrono
是一個頭檔案的名稱,同時也是一個子名稱空間:此標頭檔案中的所有元素(除了
common_type
特化)並非直接定義在
std
名稱空間下(像大多數標準庫一樣),而是定義在
std::chrono
名稱空間內定義。
此標頭檔案中的元素處理時間。這主要透過三個概念來完成:
時長 (Durations)
它們衡量時間跨度,例如:一分鐘、兩小時或十毫秒。
在此庫中,它們由
duration
類模板的物件表示,該物件將一個
計數表示 (count representation)
和一個
週期精度 (period precision)
結合起來(例如,十毫秒的
計數表示
為十,
週期精度
為毫秒)。
時間點 (Time points)
對特定時間點的引用,例如某人的生日、今天的黎明或下一班火車經過的時間。
在此庫中,
time_point
類模板的物件透過使用相對於一個
紀元 (epoch)
(對於所有使用相同 C++ 時鐘的
time_point
物件而言,它是一個固定的共同時間點)的
duration
來表示這一點。
時鐘 (Clocks)
一個將
時間點
與現實物理時間關聯起來的框架。
該庫至少提供了三種時鐘,它們提供了將當前時間表示為
time_point
的方法:
system_clock
、
steady_clock
和
high_resolution_clock
。
有關典型示例,請參閱
steady_clock
或
system_clock
。
類
duration
和
time_point
:
duration
時長
(類模板)
time_point
時間點
(類模板)
時鐘
system_clock
系統時鐘
(類)
steady_clock
穩定時鐘
(類)
high_resolution_clock
高解析度時鐘
(類)
特性 (traits)
treat_as_floating_point
視為浮點數
(類模板)
duration_values
時長值
(類模板)
common_type (duration)
duration 的 common_type 特化
(類模板)
函式
duration_cast
時長轉換
(函式模板)
time_point_cast
時間點轉換
(函式模板)
類例項化型別定義
在此名稱空間中還定義了以下
duration
例項化的便捷型別定義
hours
以小時為單位的時長
(類)
minutes
以分鐘為單位的時長
(類)
seconds
以秒為單位的時長
(類)
milliseconds
以毫秒為單位的時長
(類)
microseconds
以微秒為單位的時長
(類)
nanoseconds
以納秒為單位的時長
(類)