> C++17 > Works with or without exceptions Is anyone using C++17 features with exceptions disabled? I thought the “no exceptions” people were generally only using C++ as C-with-classes?
TOML for Modern C++
31–40 of 48 posts
Re: TOML for Modern C++
#32Earlier quoted context omitted.
Ouch. Seems like an unsolvable limitation at this point. Nice catch.
C++20 introduces “modules” which are an attempt at alleviating the problem of headers. Support, though, is lacking in major compilers’ master branch. GCC supports it if you build a certain branch from source though.
I guess C++ coders deserve the std::'s their language gives them.
Re: TOML for Modern C++
#33I don't get why C++ programmers like to keep the namespace prefixes around. I'd just add lots of "using ..." statements and make my code more readable. What's the chance of conflicts anyway when you are already dealing with a tiny fraction of the code in the current file?
You could do that in .cpp files, but it's objectively bad to do so in the header files due to namespace pollution. And now you have an inconsistency between headers and .cpp files..
Re: TOML for Modern C++
#34 for (auto& elem : *arr) {
// visitation helps deal with the polymorphic nature of TOML data
elem.visit([=](auto&& el) noexcept
{
if constexpr (toml::is_number)
(*el)++;
else if constexpr (toml::is_string)
el = "five"sv;
});
}
I thought constexpr would work at compile time but how can the compile here inside a loop "know" when this labmda will encounter an int or a string ?Re: TOML for Modern C++
#35Earlier quoted context omitted.
Yes, plenty, including Google. If anything exceptions are declining in popularity, due to non-obvious and non-local effects. Exceptions are an uber-goto, that can jump outside entire functions. Some people still like that, but very disciplined code bases (of which there are a lot in C++) tend to avoid them. At the very least, utility libraries like this one tend to err on the side of most compatible: header only, no…
> Exceptions are an uber-goto, that can jump outside entire functions. Some people still like that, but very disciplined code bases (of which there are a lot in C++) tend to avoid them. I've never heard discipline as a reason to be exceptionless, its always been performance related (specifically performance predictability).
For C++ see https://en.cppreference.com/w/cpp/language/except_spec and note that it has been removed from C++. Features are only very rarely removed from C++!
Re: TOML for Modern C++
#36> C++17 > Works with or without exceptions Is anyone using C++17 features with exceptions disabled? I thought the “no exceptions” people were generally only using C++ as C-with-classes?
All of Google's codebase, including Chromium, is OO C++ without exceptions. https://google.github.io/styleguide/cppguide.html#Exceptions
> On their face, the benefits of using exceptions outweigh the costs, especially in new projects. However, for existing code, the introduction of exceptions has implications on all dependent code. If exceptions can be propagated beyond a new project, it also becomes problematic to integrate the new project into existing exception-free code. Because most existing C++ code at Google is not prepared to deal with exceptions, it is comparatively difficult to adopt new code that generates exceptions.
Also let's note that there are more new C++ projects being created today that at any previous point in time.
Propagating the -fno-exceptions meme is harmful to the whole community.
Re: TOML for Modern C++
#37Earlier quoted context omitted.
The standard library uses exceptions, but in ways that are avoidable. Not using exceptions does necessitate avoiding the `new` operator, or allowing your program to terminate on OOM. [1] https://stackoverflow.com/questions/37700365/if-youre-in-the... [2] https://news.ycombinator.com/item?id=13354027
Many of the large C++ projects I've been on are exceptionless, but do throw an OOM exception which is caught at a very high level. That's usually the point where a crashdump is taken and some other forensics are gathered; a decent strategy is to freeze threads (if you can), release some reserve memory and try to gather evidence. Doesn't always work . . .
Re: TOML for Modern C++
#38> C++17 > Works with or without exceptions Is anyone using C++17 features with exceptions disabled? I thought the “no exceptions” people were generally only using C++ as C-with-classes?
Even code doesn't actually reach the throwing paths, exceptions and RTTI induce a huge binary size overhead that is simply not acceptable if you have binary size constraints.
Re: TOML for Modern C++
#39So it does actually require exceptions and RTTI/still forces linkage against throwing functions, etc.
Re: TOML for Modern C++
#40Hm, it looks like it is using things like std::vector and streams, etc. So it does actually require exceptions and RTTI/still forces linkage against throwing functions, etc.