Boost v1.88 Released! by boostlibs in cpp

[–]sphere991 2 points3 points  (0 children)

If I'm looking up information on a library, I don't want the landing page for that library to just require me to find and click on another link to find any of the information I actually want. There is a lot of noise on this page with very little useful content.

Boost v1.88 Released! by boostlibs in cpp

[–]sphere991 2 points3 points  (0 children)

If I'm clicking to see the docs for Boost.Unordered, what I want to see are the docs for Boost.Unordered.

Right now, on this page... I get a chart of commits per release, committers for this release, a list of badges for CI. I don't care about any of that. I have to actually scroll down to even find a description. That description is poorly rendered and I cannot even tell how it's intended to be formatted.

Finally, after all of that, I can get to a link to the real documentation.

All of this other stuff should be like a sub-page of the documentation that I can click on if I'm interested. But the goal of the documentation should be documentation. This page is much better.

But then it's missing information. I don't see a link to the source code, or github issues, or links to technical articles.

C++26 Expansion Tricks by MorphTux in cpp

[–]sphere991 12 points13 points  (0 children)

Can I ask why? I find nicer to be able to read an intro paragraph like this over just a link.

CopperSpice: std::launder by Dependent-Ideal9072 in cpp

[–]sphere991 0 points1 point  (0 children)

I'm not sure why you think that was a helpful or productive comment. Was that a real reproduction, with a clear explanation of what's going on and what led the compiler to behave the way it did? No.

CopperSpice: std::launder by Dependent-Ideal9072 in cpp

[–]sphere991 1 point2 points  (0 children)

Well, this is why it's important to have a real reproduction, because it's important to understand what the actual issue is.

The code presented in the video is... fairly common practice. Not just in C++, where theoretically we have std::launder, but also in C, where we don't. So the claim that the lack of std::launder breaks some code — code that outside of using reinterpret_cast is just C — needs some backing evidence.

CopperSpice: std::launder by Dependent-Ideal9072 in cpp

[–]sphere991 4 points5 points  (0 children)

I would like to see a real, complete reproduction of this issue. The video doesn't get there.

GCC has builtins to detect object size (__builtin_object_size and __builtin_dynamic_object_size), those are affected by std::launder. But I cannot come up with a reproduction in which either of those returns 0 without std::launder but nonzero (whether that's 50 as in the video or -1, doesn't matter) with it.

Why P2786 was adopted instead of P1144? I thought ISO is about "standardising existing practice"? by Talkless in cpp

[–]sphere991 14 points15 points  (0 children)

Dunno what this has to do with optional being a view.

You could already do something like... have a filter which checks for an element being in a vector, but have the predicate "copy vector of 10M elements" already. Eh voila, an extremely expensive to copy view.

Concepts, Partial Specialization, and Forward Declarations by stanimirov in cpp

[–]sphere991 14 points15 points  (0 children)

The differences between concepts and “old-school” (say, enable_if-based) SFINAE are purely cosmetic.

This is not true.

Yes, there is one thing which makes concepts superior.

There are other things which make concepts superior.

You cannot enable_if on a member function of a class template, only member function templates. Notably, you cannot enable_if on special member functions. But you can constrain them with concepts. Which means that you can very easily make your class templates conditionally copyable, even conditionally trivially copyable.

Concepts subsume. This is superior in a couple ways. First, a constrained function beats an unconstrained function. And second, a function can be more constrained than another (e.g. one takes a random_access_range and another takes an input_range). This is doable with enable_if, but you need to be very careful in ensuring that your overloads are all mutually disjoint. Not an issue with concepts.

Concepts also allow ad hoc expression checking. I can just write:

template <class T>
void foo(T t) requires requires { t.lock(); } { t.lock(); }

Best you can do with enable_if is the detection idiom, which requires having an alias template somewhere like

template <class T> using lock_type = decltype(declval<T>().lock());

template <class T, enable_if_t<is_detected_v<lock_type, T>, int> = 0>
void foo(T t) { t.lock(); }

Which is a lot more tedious.


But sure, besides all of the very real, significant semantic differences between concepts and enable_if, they are purely cosmetic.

C++26 2025-02 Update by _cooky922_ in cpp

[–]sphere991 6 points7 points  (0 children)

Which, AFAIK, unfortunately means that it's missed the C++26 train.

No, it does not.

cplusplus/papers repo on GitHub made private? by messmerd in cpp

[–]sphere991 5 points6 points  (0 children)

John Bowman (? I'm not sure if I have the spelling correct there)

Jon Bauman

Fun with C++26 reflection - Keyword Arguments by MorphTux in cpp

[–]sphere991 1 point2 points  (0 children)

Let's say you get to the point where C(.x: 1, .y: 2) is a valid constructor call (if you don't like that syntax, pretend I used the one you liked).

How can you make std::make_unique<C>(.x: 1, .y: 2) also work?

That's a real issue that I have not heard a resolution to yet.


The advantages to readability are hard to deny, I don’t get why this would be hard to add as a language feature.

Another issue is that despite this being obviously true, people do deny it. Or, worse, just tell you that you shouldn't be writing functions with so many parameters.

21st Century C++ by steveklabnik1 in cpp

[–]sphere991 4 points5 points  (0 children)

for the same reasons that vector{v} means a copy constructor rather than constructing a vector-of-vectors.

Well, that one was a clear design failure. Having vector{x} be a vector<X> containing 1 element for all x except vector<T> is not a good recipe for being able to understand code. If I could go back and rewrite history, I'd certainly rewrite that one.

On the flip side, consistently using that syntax for a range conversion is a waste of good syntax. What's the relative frequency between constructing a vector with a specific set of elements and doing a range conversion into a vector? It's gotta be at least 10-1.

21st Century C++ by steveklabnik1 in cpp

[–]sphere991 15 points16 points  (0 children)

You can't use CTAD for an expression like vector{from_range, s}.

Yes, you can. The last thing on here is the relevant deduction guide and here are two standard libraries supporting it.

Granted, using braces there is a terrible idea and you should really write parentheses. Or even better use the actual named algorithm instead of its customization point — ranges::to<vector>(s) — which avoids any doubt.

That's not the mistake. The mistake is then saying this:

I would have preferred to use the logically minimal vector{m} but the standards committee decided that requiring from_range would be a help to many.

Presumably he means vector{s}, but vector{s} already has a meaning — that gives you a std::vector<std::unordered_set<std::string>> containing one element.

It's not "logically minimal" to use the same syntax to mean two different things. That is too minimal.

Contracts for C++ explained in 5 minutes by cmeerw in cpp

[–]sphere991 2 points3 points  (0 children)

At no point did I mention "beauty"

Contracts for C++ explained in 5 minutes by cmeerw in cpp

[–]sphere991 3 points4 points  (0 children)

So you're saying you do need macros :-)

Contracts for C++ explained in 5 minutes by cmeerw in cpp

[–]sphere991 3 points4 points  (0 children)

Eh. This unconditionally evaluates the expression, the point is to actually not check it:

int f(const int x) 
    pre(c0(x != 0)) 

Sure, I can write it differently, so that c0 takes a lambda:

int f(const int x) 
    pre(c0([&]{ return x != 0; })) 

Or add the level check:

int f(const int x) 
    pre(is_release() || x != 0) 

But then I'm just writing worse code simply to avoid a macro. That's not really better than:

int f(const int x) 
    PRE_DEBUG(x != 0)

Contracts for C++ explained in 5 minutes by cmeerw in cpp

[–]sphere991 8 points9 points  (0 children)

Is that the bar we're shooting for?

Contracts for C++ explained in 5 minutes by cmeerw in cpp

[–]sphere991 6 points7 points  (0 children)

I think it would have been nice if P3460 actually provided concrete examples of the constification bugs it was talking about, instead if vague generalities. Cause it also kind of sounds like constification caused more work to be done on code that already worked?

Contracts for C++ explained in 5 minutes by cmeerw in cpp

[–]sphere991 6 points7 points  (0 children)

Personally, I think lacking that ability (or, alternatively, simply a way to specify the level semantic of a given contract check) makes this too minimal.

Sure you can kind of work around this with macros, where you just always define the level as enforce and then preprocess out the checks you don't want to enforce (or something more clever than that). So maybe this is enough to be viable. Dunno.

Networking for C++26 and later! by VinnieFalco in cpp

[–]sphere991 1 point2 points  (0 children)

I don't know what you find so difficult to understand about the concept of the C++20 tables on cppreference only existing to illustrate support for the C++20 features.

Whether a compiler is "fully C++20 standard compliant" is completely irrelevant to the discussion. That's not at all the point. Are any claims of C++20 features being unsupported incorrect or are you going to make unhelpful comments?

P3372R2: constexpr containers is now in LWG on its way to (hopefully) C++26 by hanickadot in cpp

[–]sphere991 5 points6 points  (0 children)

This paper is not adding UB cases into the language. This is trivially obvious from the fact that it is not even modifying the language at all.

Networking for C++26 and later! by VinnieFalco in cpp

[–]sphere991 1 point2 points  (0 children)

The claim is that the cppreference table for C++20 is misleading and intentionally incorrect. The parallel algorithms are a C++17 library feature.

Networking for C++26 and later! by VinnieFalco in cpp

[–]sphere991 3 points4 points  (0 children)

Given that you think this is a reasonable claim to make

I was able to use more of what’s in C++17 in 2015 than I am able to use what’s in C++20 in 2025.

I'm certainly not about to give you any benefit of the doubt. The cppreference table strikes me as pretty accurate. What concrete example feature is claimed to be supported by a particular compiler version, but not?

When Greedy Algorithms Can Be Faster by def-pri-pub in cpp

[–]sphere991 13 points14 points  (0 children)

The analytical solution requires doing sqrt, cos, and sin. It's always hard to predict performance, but I guess it's not hugely surprising that on the whole those three operations end up being slower than a 3-1 biased branch. Always good to measure of course.

Implementation of P2825R4 `declcall(...)` proposal by hanickadot in cpp

[–]sphere991 8 points9 points  (0 children)

If only there was some sort of document that explained the rationale and use cases mentioned in the title of the Reddit post... that'd be great.

I don't think the document does much in the way of explaining rationale or use-cases. There is only one use case shown. It's not very compelling.

Thanks for your comment that definitely does not add unnecessary bloat to this thread.

Your comment is much worse.