I must use the utc_clock<>
feature of C++20. Before, I was using the date library from Howard Hinnant date library but now I want to use the standard C++20 features (and not the date library).
The GCC version is:
gcc version 12.2.1 20221020 [revision 0aaef83351473e8f4eb774f8f999bbe87a4866d7] (SUSE Linux)
He included an example to test the functionality:
using namespace std;
using namespace std::chrono;
using namespace std::literals;
auto start = clock_cast<utc_clock>(sys_days{2015y/July/1} - 500ms);
auto end = start + 2s;
for (auto utc = start; utc < end; utc += 100ms)
{
auto sys = clock_cast<system_clock>(utc);
auto tai = clock_cast<tai_clock>(utc);
auto gps = clock_cast<gps_clock>(utc);
cout << format("%F %T SYS == ", sys)
<< format("%F %T %Z == ", utc)
<< format("%F %T %Z == ", tai)
<< format("%F %T %Z\n", gps);
}
In the CMakeLists.txt are the lines:
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
But the compiler output is always:
/home/aces/Programs/FSLockingTest/datapacket.cpp:28: error: ‘clock_cast’ was not declared in this scope; did you mean ‘clock_t’?
/home/aces/Programs/FSLockingTest/datapacket.cpp:28:20: error: ‘clock_cast’ was not declared in this scope; did you mean ‘clock_t’?
28 | auto sys = clock_cast<system_clock>(utc);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| clock_t
Is clock_cast
not implemented yet? If not, how to do the conversion? (I have tried from_sys for that but wasn't successful).
I tried to do several namespace variations; tt should compile without error.