Vladlen
Vladlen

Reputation: 138

Does GCC support C++23 std::print?

On CppCon 2022 was announced, that new official HelloWorld in C++ is now:

#include <print>

int main() {
 std::print("Hello world\n");
 return 0;
}

Do you know, is std::print available in GCC ? Maybe it needs some flag or additional library to activate?

Link to description https://en.cppreference.com/w/cpp/io/print

Upvotes: 10

Views: 10702

Answers (2)

Homer512
Homer512

Reputation: 13473

The status of C++ features is tracked via their feature test macros. cppreference.com helpfully lists those. They would be __cpp_lib_print and __cpp_lib_format for print and format, respectively.

You can then search for those macros in the C++ Standards Support in GCC and Implementation Status of libstdc++. Right now you will find no mention of __cpp_lib_print while __cpp_lib_format is listed but not implemented. So the answer is no.

You can check your own compiler with the feature testing facilities of C++. An online compiler like godbolt.org is a quick way to test most mainstream ones.


UPDATE:

std::print and std::format support had been added to GCC since version 14.

To check, just invoke

$ g++ --version

see the output and -in case- update the compiler.

Upvotes: 7

knoxgon
knoxgon

Reputation: 1243

No it does not support std::print.

Here is a list of the feature availability for C++23 in GCC and other compilers.

Upvotes: 6

Related Questions