I am trying to use the new C++20 chrono library, more specifically the new clock_cast.
If I compile on Linux with clang++ 16.0.6 it works as expected.
However, if I try to compile on MacOS I encounter the following error:
error: no member named 'clock_cast' in namespace 'std::chrono'
Clang is version 17.0.5 on the Mac, so I would expect the chrono library to be implemented, do I need to add another include?
I couldn't find anything online about this issue.
Clang version:
Homebrew clang version 17.0.5
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
Also tried with the default xcode clang version, same error.
Minimum reproducible example:
#include <chrono>
int main() {
auto time = std::chrono::high_resolution_clock::now();
auto system_time = std::chrono::clock_cast<std::chrono::system_clock>(time);
}
Compilation options:
/opt/homebrew/opt/llvm/bin/clang++ -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -isystem /opt/homebrew/Cellar/openssl@3/3.1.4/include -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -fPIC -o test.cpp.o -c test.cpp
-stdlib=libc++. Default lib might be conforming only one of the older C++ standards.