- chrono[meta header]
- std::chrono[meta namespace]
- type-alias[meta id-type]
- cpp20[meta cpp]
namespace std::chrono {
using file_clock = see below;
}
- see below[italic]
file_clock
は、ファイル時間を作るために使用されるクロックである。この時刻系は<filesystem>
ライブラリにおいてファイル作成日時やファイル更新日時を表現するfile_time_type
のために定義される。
このクロックは、TrivialClock要件を満たすクロック型の別名として定義される。別名の元となるクロックは、std::chrono
やstd::filesystem
とは異なる名前空間で定義される可能性がある。
この型がもつnow()
静的メンバ関数は、noexcept(true)
である。
file_clock
は、以下の2つ組の静的メンバ関数のいずれかを提供する:
// utc_clockに相当するクラスの別名として定義される場合
template<class Duration>
static sys_time<see below>
to_sys(const file_time<Duration>&);
template<class Duration>
static file_time<see below>
from_sys(const sys_time<Duration>&);
- see below[italic]
- utc_clock[link utc_clock.md]
- sys_time[link sys_time.md]
- file_time[link file_time.md]
もしくは
// tai_clock, gps_clockに相当するクラスの別名として定義される場合
template<class Duration>
static utc_time<see below>
to_utc(const file_time<Duration>&);
template<class Duration>
static file_time<see below>
from_utc(const utc_time<Duration>&);
- see below[italic]
- tai_clock[link tai_clock.md]
- gps_clock[link gps_clock.md]
- utc_time[link utc_time.md]
- file_time[link file_time.md]
これらの戻り値となるtime_point
のDuration
は、入力のtime_point
から計算される。
未規定
未規定
#include <fstream>
#include <chrono>
#include <filesystem>
namespace chrono = std::chrono;
namespace fs = std::filesystem;
int main()
{
std::ofstream{"regular.txt"};
// ファイルの最終更新日時を変更する
fs::file_time_type tp = chrono::file_clock::now();
fs::last_write_time("regular.txt", tp);
}
- chrono::file_clock[color ff0000]
- fs::file_time_type[link /reference/filesystem/file_time_type.md]
- fs::last_write_time[link /reference/filesystem/last_write_time.md]
- C++20
- Clang: 9.0 [mark noimpl]
- GCC: 9.2 [mark noimpl]
- Visual C++: 2019 Update 3 [mark noimpl]
file_clock
breaks ABI for C++17 implementationsfile_clock
は当初、独立したクラスとして定義することを予定していたが、C++17のファイルシステムライブラリで定義されるfile_time_type
のABI互換性を破壊してしまうことがわかったため、実装定義されるクロックの別名としてfile_clock
が定義されることになった