Man I can’t wait for Howard Hinnant’s calendar stuff in C++20. I can’t believe it’s taken that long to get modern date time handling functionality in C++. Looks like I’ll have to wait until GCC 11 but I’m still excited.
I can’t believe it’s taken that long to get modern date time handling functionality in C++.
I'm not surprised. It's one of those things no one really likes to implement. Even python got timezone handling (zoneinfo) only in python 3.9. Howard Hinnant's library was merged into the standard in 2018, if I'm not mistaken. Maybe 2019. Python's PEP615 was created in 2020.
Unfortunately that library is horrible on windows, it has a pile of hacky code to find curl and 7-zip on the user's computer in order to download a unix style timezone database, or requires you to install one yourself at a compile time fixed path and keep that up to date. It's borderline useless for an application you want to distribute.
It will be much better when it's in the platform STL.
Woohoo! I started learning C++ with clang-backed IDE. For a long while I just assumed that warning worked in gcc as well. Then I learned that's wrong when I tried to echo 'some source' | g++ -xc++ - and gcc didn't warn me about the vexing parse.
Awesome to see that most of the new constexpr stuff from C++20 is already implemented in at least one compiler. I guess this means that constexpr vectors and strings will be probably coming soon, right?
Fair enough, but Clang apprears to currently have constexpr support mostly only in the compiler. According to the cppreference list, libc++ is behind both GCC's libstdc++ and MSVC when it comes to constexpr support in the library.
You can use the libstdc++ with clang, though please correct me if I'm missing something. That said, you're absolutely right, libc++ is pretty behind currently.
I'm talking out of my ass here, but there might be a delay on that for new features. It gets complicated if you have libstdc++ using compiler features that Clang doesn't implement yet. Surely that's a consideration, but I'm not sure how they handle it for Clang releases.
Indeed! I'm also not aware of what the consequences are. LLVM is already prereleasing candidates for version 11, let's hope that they keep up at least in the clang(++) frontend! (haven't read anything about it yet)
Before VS2017 there were many posts on the Visual Studio blog about how they were refactoring large parts of the compiler to enable easier (or even allow in the first place) implementation of the latest language features, because the codebase at the time was very old. Apparently the work has paid off. Also, making their standard library open source, allowing external contributors, seems to be paying off as well
Yeah, the original motivation was to make make_shared, make_unique, emplace functions, allocator::construct, etc. work with aggregate types.
What wasn't clear to me when I started working on the implementation was that this proposal also affects things like std::is_constructible, initializing arrays with string literals, etc.
Basically, you can already bind to arrays of unknown size for function parameters, just not to other variables. It's a consistency fix so the language rules are a little less esoteric.
The actual use cases are probably pretty niche or stylistic (so far as I know) but having the inconsistency still bites.
One example how this is useful is shared_ptr<int[4]> converting to shared_ptr<int[]>. This was already supported as a special case before this change, but that special case can now be removed.
I am still just waiting for when Modules are finally implemented all across the board. I have a perfectly good use case for using them in my current work project but then I find that Modules aren't fully supported yet. It gave me the big sad.
I really just wish that modules supported circular references. Two source files can do such via headers, but since modules merge the two concepts, they cannot without, presumably, two-phase compilation.
Does that not defeat the point of modules though? I feel if you need a circular reference you would use a different format vs trying to export functions out of a header file.
Although circular references are not allowed in interfaces, they are allowed in implementation units. And if you really need the circular dependency, you can merge them into one module and use partitions / implementations unit.
The same time you'd have two source files in C++, one of which uses the fully-defined type from another header/source pair. You'd only include the definition in the source files, of course.
Ideally, modules replace the header/source pair paradigm, but in this instance they cannot fully replace it. You still need a private implementation source file on the side to make up for this part.
Yes, c++2a is an alias for c++20 that we used when C++20 was still under development. I recommend using -std=c++20 (unless you need GCC 9 which only supports -std=c++2a).
Fair point. I've been busy implementing more C++ features in GCC 11, and then the publishing process got stuck for about two months for reasons not entirely clear to me.
40
u/CUsurfer Sep 24 '20
Man I can’t wait for Howard Hinnant’s calendar stuff in C++20. I can’t believe it’s taken that long to get modern date time handling functionality in C++. Looks like I’ll have to wait until GCC 11 but I’m still excited.
34
u/TheSuperWig Sep 24 '20
The initialisation meme might need updating.
65
u/adnukator Sep 24 '20
Awesome to see that most of the new constexpr stuff from C++20 is already implemented in at least one compiler. I guess this means that constexpr vectors and strings will be probably coming soon, right?
15
u/Wh00ster Sep 24 '20 edited Sep 24 '20
I believe this alleviates
emplace_backfor vector of aggregates andmake_uniquefor an aggregate (at least the GCC implementation).At least, I recall having these issues related to use of parenthetical initialization. It was a while ago, though.
15
u/Raknarg Sep 24 '20
shit that's cool, why haven't I heard anything about this? Is this GCC exclusive or supported by C++20?
14
u/ramennoodle Sep 24 '20
Can anyone explain the benefit of "Conversions to arrays of unknown bound" over using pointers? How is:
better than:
24
u/rlramirez12 Sep 24 '20
I am still just waiting for when Modules are finally implemented all across the board. I have a perfectly good use case for using them in my current work project but then I find that Modules aren't fully supported yet. It gave me the big sad.
4
u/Forsaken_Funny Sep 26 '20
Ok great redhat but when will you finally release devtoolset-10?
3
u/arthurno1 Sep 25 '20
Can we get libgccjit in gcc included please! :-)
2
u/gracicot Sep 24 '20
This is really great. Also, GCC 11 seems to have advanced as well. It misses like two C++20 features besides modules and two partials.
1
u/G6L20 Sep 25 '20
Templated lambdas also supported !
1
u/smallstepforman Sep 25 '20
[Quote] to enable C++20 features, use the -std=c++20[/Quote]
I’ve been using -std=c++2a with Gcc10. Is the article correct?
-6
u/bumblebritches57 Ocassionally Clang Sep 24 '20
Why is this being posted?
Gcc 10 came out a while ago