If it doesn't, do you know what compiler or version will?
See cppreference/format.
It's 2023 Now! Cheers!
GCC 13, CLANG 14 and MSVC 16.10/VS 2019 all have the {fmt} based std::format available in respective standard libraries.
Hopefully we'll have C++23 std::print available soon.
See Compiler support here :-
gcc (libstdc++)
clang (libc++)
msvc (vc++)
Does gcc support C++20 std::format?
Not yet!
There's no compiler support yet, not even gcc 11. See Text formatting in Library features.
Compiler support for C++20 library features
As of today (November 15, 2022), GCC 12.2 does not support this feature. Or rather, its standard library implementation doesn't support it (cause it's a library feature, not the compiler-one).
NOTE: The feature is mentioned as implemented in GCC 13.0 (link)
You can try Clang 14.0.0 and upward for now, but note following:
In libc++ of Clang 14.0.0 std::format support added but: "The paper is implemented but still marked as an incomplete feature. Not yet implemented LWG-issues will cause API and ABI breakage" (link)
In libc++ of Clang 15.0.0 and later, this feature can be enabled with the -fexperimental-library compiler flag (link)
Also you can try MSVC 16.10 and upward. Support of std::format is mentioned as complete.
Standard library current status can be seen here:
GCC: libstdc++
Clang: libc++
MSVC: msvc-170
Now libstdc++ has implemented it!
https://gcc.gnu.org/pipermail/libstdc++/2022-November/054991.html
GCC 13 has added support for std::format. According to cppreference, as of GCC 13, no gaps remain in its C++20 support (in both the core language and the standard library).
This bugzilla ticket notes that some C++23 extensions to std::format have not yet been implemented.
GCC 13 can be expected around April 2023.
The GCC trunk installation on compiler explorer includes std::format support.
Related
If it doesn't, do you know what compiler or version will?
See cppreference/format.
It's 2023 Now! Cheers!
GCC 13, CLANG 14 and MSVC 16.10/VS 2019 all have the {fmt} based std::format available in respective standard libraries.
Hopefully we'll have C++23 std::print available soon.
See Compiler support here :-
gcc (libstdc++)
clang (libc++)
msvc (vc++)
Does gcc support C++20 std::format?
Not yet!
There's no compiler support yet, not even gcc 11. See Text formatting in Library features.
Compiler support for C++20 library features
As of today (November 15, 2022), GCC 12.2 does not support this feature. Or rather, its standard library implementation doesn't support it (cause it's a library feature, not the compiler-one).
NOTE: The feature is mentioned as implemented in GCC 13.0 (link)
You can try Clang 14.0.0 and upward for now, but note following:
In libc++ of Clang 14.0.0 std::format support added but: "The paper is implemented but still marked as an incomplete feature. Not yet implemented LWG-issues will cause API and ABI breakage" (link)
In libc++ of Clang 15.0.0 and later, this feature can be enabled with the -fexperimental-library compiler flag (link)
Also you can try MSVC 16.10 and upward. Support of std::format is mentioned as complete.
Standard library current status can be seen here:
GCC: libstdc++
Clang: libc++
MSVC: msvc-170
Now libstdc++ has implemented it!
https://gcc.gnu.org/pipermail/libstdc++/2022-November/054991.html
GCC 13 has added support for std::format. According to cppreference, as of GCC 13, no gaps remain in its C++20 support (in both the core language and the standard library).
This bugzilla ticket notes that some C++23 extensions to std::format have not yet been implemented.
GCC 13 can be expected around April 2023.
The GCC trunk installation on compiler explorer includes std::format support.
If it doesn't, do you know what compiler or version will?
See cppreference/format.
It's 2023 Now! Cheers!
GCC 13, CLANG 14 and MSVC 16.10/VS 2019 all have the {fmt} based std::format available in respective standard libraries.
Hopefully we'll have C++23 std::print available soon.
See Compiler support here :-
gcc (libstdc++)
clang (libc++)
msvc (vc++)
Does gcc support C++20 std::format?
Not yet!
There's no compiler support yet, not even gcc 11. See Text formatting in Library features.
Compiler support for C++20 library features
As of today (November 15, 2022), GCC 12.2 does not support this feature. Or rather, its standard library implementation doesn't support it (cause it's a library feature, not the compiler-one).
NOTE: The feature is mentioned as implemented in GCC 13.0 (link)
You can try Clang 14.0.0 and upward for now, but note following:
In libc++ of Clang 14.0.0 std::format support added but: "The paper is implemented but still marked as an incomplete feature. Not yet implemented LWG-issues will cause API and ABI breakage" (link)
In libc++ of Clang 15.0.0 and later, this feature can be enabled with the -fexperimental-library compiler flag (link)
Also you can try MSVC 16.10 and upward. Support of std::format is mentioned as complete.
Standard library current status can be seen here:
GCC: libstdc++
Clang: libc++
MSVC: msvc-170
Now libstdc++ has implemented it!
https://gcc.gnu.org/pipermail/libstdc++/2022-November/054991.html
GCC 13 has added support for std::format. According to cppreference, as of GCC 13, no gaps remain in its C++20 support (in both the core language and the standard library).
This bugzilla ticket notes that some C++23 extensions to std::format have not yet been implemented.
GCC 13 can be expected around April 2023.
The GCC trunk installation on compiler explorer includes std::format support.
I would like to try some of the new features that will make it to the C++2014 revision like std::make_unique and the std::filesystem functionnalities. I use ubuntu 14.04 and GCC/G++ 4.8 (with libstdc++-4.8-dev installed), and the flag -std=c++1y set. But there is no std::make_unique when including <tr1/memory>, and no <experimental/...> headers.
What do I need to do to be able to use some of those new features ?
Thanks !
<tr1/memory> is not a C++14 standard header. You simply want <memory>. Same for <dynarray>.
However, neither are supported in GCC 4.8. You need to upgrade to GCC 4.9 or clang 5.
The GCC compiler support status for C++1y can be checked on the Language Features status page, and the library support on the Library Support status page.
I try to use emplace() function for an unordered_map and compiler says that no such function exists.
I put -std=c+11 and it says cc1plus.exe: error: unrecognized command line option '-std=c+11'
Can i somehow use C++11 functionality with mingw?
From the GCC documentation
C++0x was the working name of a new ISO C++ standard, which was then
released in 2011 as C++11 and introduces a host of new features into
the standard C++ language and library. This project seeks to implement
new C++11 features in GCC and to make it one of the first compilers to
bring C++11 to C++ programmers.
C++11 features are available as part of the "mainline" GCC compiler in
the trunk of GCC's Subversion repository and in GCC 4.3 and later. To
enable C++0x support, add the command-line parameter -std=c++0x to
your g++ command line. Or, to enable GNU extensions in addition to
C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7
and later support -std=c++11 and -std=gnu++11 as well.
So, for gcc 4.3 through 4.6 use -std=c++0x, for later version use -std=c++11. Library support for map::emplace was added in gcc 4.8
From clang's C++11 support status website, http://clang.llvm.org/cxx_status.html , it says, "Initializer List" and "Lambda Expression" are all supported starting from version 3.1.
However, using LLVM/Clang trunk (3.2), compiling against initializer list and lambda expression will yield error messages.
Does anyone know if Clang >3.1 supports those features?
By default, clang++ will not enable the C++11 features - you have to pass an additional flag during compilation.
clang++ -std=c++11 [input files...]
Or
# enables some additional C++11 extensions GCC has
clang++ -std=gnu++11 [input files...]
Additionally, you can switch between using libstdc++ and Clang's own libc++, which are different implementations of the C++ standard library. libc++ in some cases might have a better implementation of the C++11 standard than your existing libstdc++ library.
# uses clang's C++ library in C++98 mode
clang++ -stdlib=libc++ [input] # uses clang's C++ library
# uses clang's C++ library and enables C++11 mode
clang++ -stdlib=libc++ -std=c++11 [input]
The latter is important if you're using Clang in an environment with an outdated version of libstdc++ (like Mac OSX), but note that the two C++ libraries are not compatible with each other, so you would have to rebuild any dependencies against libc++ if you were to use that.
The page at http://clang.llvm.org/cxx_status.html is confusing at best. Currently, the released 3.1 version does not support initializer lists or lambdas (so I've switched back to GCC 4.8 for the time being).
You can always check clang support for features using the __has__feature macro, according to the instructions here:
http://clang.llvm.org/docs/LanguageExtensions.html#checking_language_features
For example, __has_feature(cxx_generalized_initializers) or __has_feature(cxx_lambdas) will return true if those features are available and enabled.
Personally, I'm expecting those features to be ready by clang 4.0, which is expected to be released with the next Xcode (likely June 2012).
-- Edited to clarify the versions I've been testing -- clearly, clang versioning is more complex than I had realized.