Live data from Hacker News

TOML for Modern C++

marzer.github.io

11–20 of 48 posts

Re: TOML for Modern C++

#11
post #7

> 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

In other words, that codebase is without exceptions, without exception.

Re: TOML for Modern C++

#13
post #7

> 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

Thanks - I’d seen that section before, but hadn’t noticed that elsewhere the document says “code should target C++17“.

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?

Re: TOML for Modern C++

#14

Earlier quoted context omitted.

All of Google's codebase, including Chromium, is OO C++ without exceptions. https://google.github.io/styleguide/cppguide.html#Exceptions

In other words, that codebase is without exceptions, without exception.

Exceptional observation.

Re: TOML for Modern C++

#15
post #7

> 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?

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, user-chosen allocators, etc.

Re: TOML for Modern C++

#16
post #2

I 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?

Besides the header issue mentioned in the sibling, sometimes the context is important too, for an example from Python, no one would `from os.path import join`— you always use `os.path.join` in its entirety.

I have definitely seen `from os.path import join` in some ugly ML github repos.

Re: TOML for Modern C++

#17
post #9
post #3

Earlier quoted context omitted.

It's a header-only library, it would effectively add "using" statements anything that included the library.

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.

Re: TOML for Modern C++

#18

Earlier quoted context omitted.

All of Google's codebase, including Chromium, is OO C++ without exceptions. https://google.github.io/styleguide/cppguide.html#Exceptions

In other words, that codebase is without exceptions, without exception.

std::bad_alloc would like to have a word with you.

Re: TOML for Modern C++

#19
post #7

> 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?

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…

Thanks. Do you know what the knock-on effects are of disabling exceptions in modern C++? Are there parts of the language or standard library that won’t work without exceptions?

Re: TOML for Modern C++

#20
post #13

Earlier quoted context omitted.

All of Google's codebase, including Chromium, is OO C++ without exceptions. https://google.github.io/styleguide/cppguide.html#Exceptions

Thanks - I’d seen that section before, but hadn’t noticed that elsewhere the document says “code should target C++17“. 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?

No, nothing in C++ has a hard dependency on exceptions. Custom allocators can be used to report allocation failures in some way other than throwing an exception, and other than that the standard library only uses exceptions to report precondition violations; things which are expected to sometimes fail (such as filesystem operations) can report error codes instead.
Post reply on HN