TOML for Modern C++
marzer.github.io
marzer.github.io
That, and it's not as configurable (e.g. no support for exception-less).
for (auto& elem : *arr) {
// visitation helps deal with the polymorphic nature of TOML data
elem.visit([=](auto&& el) noexcept
{
if constexpr (toml::is_number<decltype(el)>)
(*el)++;
else if constexpr (toml::is_string<decltype(el)>)
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 ?So it does actually require exceptions and RTTI/still forces linkage against throwing functions, etc.
As an example, Firefox uses STL without RTTI or exceptions.
> 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?
https://google.github.io/styleguide/cppguide.html#Exceptions
Do you know if there are any parts of the C++17 language or standard library that are disallowed in Google’s code because those parts don’t work without 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.
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, user-chosen allocators, etc.
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...
I've never heard discipline as a reason to be exceptionless, its always been performance related (specifically performance predictability).
In any case, exceptions are really only a performance problem if there are frequent. [1] Modern compilers and machines have near zero overhead for unthrown exceptions and 20x the overhead of an if-else.
Chances are quite good that you have bigger performance problems than exceptions.
[1] https://stackoverflow.com/questions/13835817/are-exceptions-...
The idea being that in an area where you'd like performance to be predictable, even in cases of unexpected results, Sum types or if/else give the same performance all the time.
Your argument makes absolutely no sense. Exceptions are used to handle exceptional events, the kind of stuff that would crash and shutdown your program. Exceptions are used to establish sanity checkpoints where any exceptional event can be caught and either recover from it or fail gracefully. Performance is measured on the happy path, and exceptions fall in the exact opposite of the happy path.
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++!
Your statement is either disingenuous or entirely clueless.
The only rationale that Google presented to not use exceptions is that they use a lot of legacy code that was designed without exception handling, and thus it's problematic for then to integrate modern C++ code with old exception-free code. For Google, the only problem with exceptions is their own personal technical debt. That's it. It's in their FAQ.
Enough with this nonsense.
https://google.github.io/styleguide/cppguide.html#Exceptions
> Exceptions are an uber-goto, that can jump outside entire functions.
That statement is far from being correct or an appropriate description. Exceptions are as much like goto statements as are return statements, and no one in their right mind would describe a return statement as an uber-goto statement.
> Some people still like that, but very disciplined code bases (of which there are a lot in C++) tend to avoid them.
Again, that assertion makes no sense at all.
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.
This all applies regardless of the C++ standard, of course.
I guess C++ coders deserve the std::'s their language gives them.
namespace foo::_bar {
using namespace ::acme::widgets;
/* internal helpers go here */
inline namespace exports { /* public API goes here */ }
}
namespace foo::bar { using namespace _bar::exports; }"Remember, there is nothing wrong with using `from package import specific_submodule!` In fact, this is the recommended notation unless the importing module needs to use submodules with the same name from different packages."
I haven't dealt with a lot of C++ code but I feel like I see a lot of `using namespace ...` and haven't seen much `using ...;` (which I think is more readable/acceptable)
[1] https://github.com/psf/requests/blob/df918c066fa275abc2bb0c9...
[2] https://docs.python.org/3/library/os.html#os.walk
[3] https://docs.python.org/3/tutorial/modules.html#importing-fr...