u/germandiago

▲ 9 r/cpp

C++ profiles: a chance to fix some annoying defaults? Brainstorming and ideas.

Hello everyone,

Lately I have been thinking about the opportunity that profiles could give to C++ for "better defaults" and "cleanups".

Which profiles would you like to see in an eventually profile-enforced version as "standard" or "enabled by default" that you think can be fit reasonably?

I will start:

- ununitialized variables: must use [[indeterminate]]
- [[nodiscard]] by default? Would that be possible? Maybe this changes the meaning.
- hardened std lib guarantee?
- type safety/bounds safety (in user code)
reddit.com
u/germandiago — 1 day ago

Avoiding dangling in this situation. It is possible with current C++26 technology?

TL;DR since I am working, no time.

This:

boost::urls::url_view dbRootUserUrl( config.orgsDataAdminConnectionString .or_else([] { throwSomeException("Missing string with value"); return std::optional<std::string>{}; }) .value());

where value() returns a std::string from an optional, hence, a temporary, created a silent dangling reference for me.

Could this be avoided nowadays with some restriction? I am thinking of equivalent techiques to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2255r0.html.

In the case od url_view, it takes a std::string_view (by value).

This should be forbidden/detected/restricted?

How?

reddit.com
u/germandiago — 7 days ago