You are not logged in.
I'm a newbie to C++, but I'd like to use the new <format> header from C++20.
The documentation says it's now supported since clang14.
So installed clang, llvm, llvm-libs, libc++ and libc++abi.
And I tried:
#include <iostream>
#include <format>
using namespace std;
int main(void)
{
vector<double> v {1.23, 45.42, 0.441, 1342.8, 61.5, 32.1};
for (const auto & n : v)
cout << format("{:>7}\n", n);
return EXIT_SUCCESS;
}
Alas it says:
$ clang++ -Wall -std=c++2a -o main main.cpp
main.cpp:2:10: fatal error: 'format' file not found
#include <format>
^~~~~~~~
1 error generated.
What am I missing here?
Last edited by interrupt (2022-07-05 08:38:28)
Offline
You would have to pass "-stdlib=libc++" to clang++ otherwise it uses GCC's libstdc++ and not LLVM's libc++. You'd also need to rebuild libc++ with "-DLIBCXX_ENABLE_INCOMPLETE_FEATURES=ON" (for an explanation see: https://stackoverflow.com/a/71778011).
Offline
Okay, I see - thanks for the info.
Guess it's safer to still use fmt instead until the implementation is complete.
Offline