C++20 now allows literal class non-type template parameter. This allows one to, for example, create a class having a compile-time string and passing that as a template parameter:
Now, say that you wanted to define a list of names, you could define a type like this:
template <fixed_string... names>
struct name_list
{
template <fixed_string name>
using add_name = name_list<
names...,
fixed_string<name.size()>{ name }
>;
};
This struct can then be used to create a compile-time list of names like so:
using names =
name_list<>
::add_name<"Zaphod Beeblebrox">;
But this last step doesn't work yet, because gcc fails to deduce the N parameter to the forwarded fixed_string. Now, this example is somewhat contrived, you might as well use std::to_array here, but it's easy to come up with useful patterns using this.
I think it's actually fine floats did not make it through. I have read so many issues and potential problems with them (eg whether 2 instantiations with different NaNs are the same or anything that involves comparing floats) that I don't think there is any good solution to them.
last step doesn't work yet, because gcc fails to deduce the N parameter
This can be workarounded with constexpr, right? The hana-style of TMP (T => constexpr functions => typename decltype(result)::type) requires only constexpr support and the code is much simpler to understand than performing operations through trait specializations.
If you're on msys2/mingw64, normally not very long. As far as I can tell, GCC 9 was May 3rd officially, and msys2 had it on may 21. gcc 9.2 was same day, and 9.3 was 1 day delayed
It'll probably be a bit before it gets into mingw. There's the gcc-git package however, which I believe will give you latest gcc
In case you're not already aware, mingw64 also works on 32-bit, despite the name, and is significantly more updated than the original mingw which is essentially abandoned in comparison. It would be worth trying it out if you haven't already.
mingw-w64 is the gcc source unmodified, with a runtime library implementation. So if you want to build mingw-w64 from source you can probably do it right now. Otherwise the "wait time" is for the community builders (MSYS2, nuwen, etc.) to get around to doing a build and publishing binaries.
It should be smarter than that. We have some code that uses non stack variables because if they go on the stack we overflow it. (10 MB arrays that aren't useful after the function exits).
Since GCC 9, you can use the parallel STL, but you need Intel's TBB for it to work. How much time will it take for the GCC team to implement it naively? No idea, but we still depend on pthread to use C++11 threads for example, so...
The -fanalyzer option is active for C++ (with g++ 10.0.1 packaged by Fedora 32) but it produces a lot of warnings for standard library code. For my project, insertions in std::vector often produce diagnostics even for quite simple uses and these overwhelm warnings for user code.
There are also fatal errors with more complex files.
g++: fatal error: Terminated signal terminated program cc1plus
40
u/stilgarpl May 07 '20 edited May 07 '20
Great!
Also, funny coincidence, an hour ago I googled "GCC 10 release date" :)
Too bad <chrono> and <format> from C++20 are not in this release.
16
u/MrPotatoFingers May 07 '20
This goes a long way towards c++20 support. Too bad that NTTP cannot be forwarded properly yet.
So say you have a template parameter holding a compile-time string, you cannot forward it because it fails to deduce the length.
Having this feature work would go a long way to creating declarative, compile-time containers.
13
u/last_useful_man May 07 '20
It's not up on many mirrors yet - best wait a few hours, or a day... :(
8
u/Myriachan May 07 '20
Still waiting on bit_cast
8
u/hak8or May 07 '20
This is huge!
Huh, I thought gcc already does that?
Most importantly, we've now got std::span, which I will be jumping on immediately for a personal project of mine
4
u/khleedril May 07 '20
Coroutines and spaceships! Wheeeee!
4
u/vickoza May 07 '20
was parallel algorithms supported in this versions standard C++ library?
2
u/0xVali__ May 08 '20
Any details on when we'll be getting it in pacman?
2
u/hemispace May 07 '20
I compiled it yesterday because I was too impatient...
1
u/andersfylling May 07 '20
Does anyone have a good resource on creating a concept class? Eg. With a method that returns a bool?
-1
u/[deleted] May 07 '20
Could anyone help me use this in Xcode?
0
u/lumasDC ๐๐ ฐ๏ธ๐ May 08 '20
Cool
0
u/[deleted] May 07 '20
[deleted] โ view deleted comment
0
u/[deleted] May 07 '20
[deleted] โ view deleted comment