A very quick update on how we use C++ standards in LibreOffice to finish off this afternoon.
So yeah, we're still using C++ 17, almost there's one thing that keeps cropping up.
I think Noah will try to sneak it in twice and Mike wants.
This is this unsuspecting standard from Kars thing where you have a string view of characters
and you want to get an integer or floating point value out of that and there's a standard
form function for that.
Unfortunately it's not in Libre standards C++ 8 or only in 8 and only in 11 for floating
point values which we don't have, we're still stuck at 7.
So people keep trying to add that to the unolibraries and I as the gatekeeper of these unolibraries
which we never want to change because then we have these maintenance problems.
I keep banging them back that we don't need that, we don't need to add anything there
because we'll have C++ 17 functionality for it anyway and I keep saying that for years
now.
At one point we'll get there, I'm pretty sure.
So yeah, just C++ 17 for now still but of course we're making use of whatever becomes
available in the later standards so that C++ 20 is out for two, three years now and C++
23 is almost finished, it's the standardizing stuff takes its time but it's quite frozen
by now.
And then there's always these small things mostly in the standard library that are easy
to approximate and then we usually make use of those ideas in our own code and have one
header file, one include file where we either use the original alias to our O3 etl namespace
or implement our own approximation which we then throw out once we have that available.
So this is the span thing similar to the string view where you just have a range of values
start and length.
Then these comparison functions they are very interesting if you don't know them then
check them out so you always have a hard time comparing two integers in C and C++ if they
are of different types signed and unsigned and you get surprising results and finally
in C++ 20 they decided to come up with ugly syntax functions but they will do the right
thing whatever types you throw at them and we have at least one place where we use them
by now for good measure.
And another example is these standard unreachable magic function that they introduced we still
have a macro for that to approximate it so if there is a place in your code where you
can't reach so a default in a speech and you don't want to return any nonsense from that
and the compiler would warn you that you don't have a return statement there then just add
an unreachable there to tell the compiler this is impossible to reach anyway.
Then there is bigger features or beyond library features that we try to make use of one way
or another for example the C++ 20 const eval similar to const expression where you have
something that should be computed at compile time and const expo is do it at compile time
if possible otherwise do it at runtime and const eval is forcing you to do it at compile
time and the trick there is if you have a function that has some assert and you make
that function a const eval function then if the assert would not hold then you get a compilation
error instead of just a runtime error later on or not even an error if you build with
the asserts disabled and we make use of that in some places like this we have this color
class and I think Noel again at one point tried to get rid of the ambiguity whether
it has alpha channel or not so we now have a constructor that wants to make sure you
pass in some value that doesn't have an alpha channel in there so we have an assert in there
and if we have const eval in the latest compilers then we use it and then we would get a compiler
at compilation time error already if you pass in some value that does have an alpha channel
after all so that helped the improvement of the changing the code from the old semantics
to the new semantics but so we have an if around that if have cpp const eval then use
const eval otherwise we use const expo and in our configure script we have lots of checks
whether we can use const eval and unfortunately only clang by now even the latest compiler
versions we have five checks in there for bugs that we discovered with all these const
eval implementations and clang the latest one has all its bugs sorted out but gcc and
the Microsoft compiler still can't use it so that shows how if you have a feature sheet
of what the compiler support and there is ticks for their adult trust that too much if you
then actually try to use it you run into all kinds of issues and then of course coming
up is issues there even even bigger way you can't use some if death trickery or some some
include file where you approximate things biggest two things that come to my mind are
the concepts in c++ 20 which would make code really more readable but which is hard to
do in some macro way we have one place I think by now where we have again around this requires
thing we have an if death or if we have a c++ 20 implementation that supports it and there
is one place where we where we have some function that internally there's some dangerous dynamic
casting and you know proxies didn't support dynamic casting so I wanted to make sure that
we never use that function on a template type that does that is a you know could be you
know proxy so I came up with this wonderful and requires cloth there to to if you have
a lady new enough compiler to get that sorted out at runtime and otherwise we ignore it
and even bigger thing is modules and I guess we will have to wait for for others to come
up with real real implementations of that or real world usage to see how we would make
use of them but even if these features are out in the dist in the distant future in some
cases still what we already can do is try to force the compiler is hard to to run our
code and demonstrate to them that they what what bugs they have worried what bugs are
in the standard library implementations if they introduce new things so what I do is
opt into this thing to use whatever compiler you use with the latest c++ you version that
compiler implements which is typically c++ 23 by now and then have a big matrix of of
platforms and compilers and libraries runtime standard long term standard runtime libraries
to build on and and find all kinds of interesting bugs whenever I update one of those things
and then mail the people mail Jonathan that he introduced something new in lip see lip
standard c++ that doesn't get clang that doesn't make clang happy and so forth and these people
are happy that we are the guinea pigs for them and that's it I guess we have time for
question if there's any questions I'm not prepared for that who do you contact if you
find it back in the Microsoft compiler oh they do have a web form now that you can fill
in and I think I even got a response monster wow Mike again ski brought that up okay maybe
one more question since we're at the end of the track so what's the status of of modules
in compilers because as far as I know only Visual Studio does it and does it kind of
sort of no I think they're all three by now in their head trunk versions they support
them I think they claim it works but I didn't ever try it sorry a module is a new way of
organizing your so that you don't have this issue of having all these includes that you
need to include this is like pre-compiled a newer version of pre-compiled headers actually
yeah yeah that sums it up okay then thanks again thanks