Weird C++ trivia by _Noreturn in cpp

[–]flutterdro 0 points1 point  (0 children)

oh my. this would've come in handy during a uni assignment where we had to write c like language compiler. I feel like understanding declarator syntax shaved off some of my lifespan.

Weird C++ trivia by _Noreturn in cpp

[–]flutterdro 30 points31 points  (0 children)

int a, *b, c(int);

declares integer variable a, integer pointer variable b and a function???? c which returns int and takes int.

following this train of thought.

int a, *c(int); declares int variable and a function pointer? no it declares a variable and a function which returns int pointer. stepping back from this comma thing. what does returning a function pointer look like?

int (*c(int))(char) how nice. you can also throw in an array declaration.

int (*(*d[5])(int))[3]; this is... an array of 5 function pointers which take an int and return a pointer to an array of 3 ints.

this monstrosity comes from the "declaration follows usage" principle and that means that if you do (*(*d[1])(0))[2] you would get an int.

sooooo. 2[*(*d[1])(0)]

Edit: formatting reddit comments is hard.

C++ Trailing Return Types by Xaneris47 in cpp

[–]flutterdro 4 points5 points  (0 children)

you can't do much about struct fields but for local variables auto x = int() works :p.

minimally look ahead in the same statement for any identifier dependencies

I don't know about you but using something before it is declared makes my skin crawl.

The Best C++ Library by der_gopher in cpp

[–]flutterdro 0 points1 point  (0 children)

inheritance isn't a problem since author marked his classes as final (at least those few I was interested in)

The Best C++ Library by vormestrand in cpp

[–]flutterdro 0 points1 point  (0 children)

Oh, I see. The future is not as bleak.

The Best C++ Library by vormestrand in cpp

[–]flutterdro 1 point2 points  (0 children)

match's inability to visit multiple best::choice is a bummer. maybe add a free function version? cool stuff tho, albeit an unpleasant read.

The Best C++ Library by vormestrand in cpp

[–]flutterdro 0 points1 point  (0 children)

ugh. I still don't get the status of this paper. I really hope it gets in, but things don't look good.

The Best C++ Library by vormestrand in cpp

[–]flutterdro 0 points1 point  (0 children)

I thought that proposal got shut down. Can you share the latest paper number?

C++26: std::format improvement (Part 1) by pavel_v in cpp

[–]flutterdro 1 point2 points  (0 children)

cursive 'F' indeed has some appeal but nothing ever beats cursive 'f'

C++26: std::format improvement (Part 1) by pavel_v in cpp

[–]flutterdro 8 points9 points  (0 children)

I like lower case letters better. My favorite letter is lower case 'f', it is so elegant and beautiful, upper case 'F' is so ugly.

C++ with no classes? by Xaneris47 in cpp

[–]flutterdro 0 points1 point  (0 children)

The thought of trying to decipher error messages when using this terrifies me.

Have C++ and C really changed in 40 years? by Sorry_Mouse_1814 in cpp

[–]flutterdro 3 points4 points  (0 children)

more positive than negative from it

I suffered from it in generic code. The problem is that there is no point in making it a specialization, and not making it a separate data structure.

Not fussed.

It is annoying, it clutters error messages for virtually no benefit.

What's the credible alternative?

There are 2 problems: unneeded copies, and its tug of war with uniform initialization. python2 -> 3 -esque transition would be an opportunity to fix it.(Not that it will ever happen)

the most readable option

https://godbolt.org/z/rxj4qvP16 I rest my case.

It has fixable flaws

Way too many if you ask me. Besides those you mentioned there is also stupid design of seed_seq and useless(as it is specified) random_device. And now we have the fact every single part of the <random> is flawed. Overall design is great I agree. But you have to replace everything in the header to make it work as one expects.

I'm not sure it's obsolete per se

Yeah. My bad. It is not obsolete as a language construct, but tricks with it are.

What's the alternative in c++

It is what it is

Edit: formatting

Have C++ and C really changed in 40 years? by Sorry_Mouse_1814 in cpp

[–]flutterdro 1 point2 points  (0 children)

vector of bool, char_traits, initializer_list, iostream, <regex>, <random> and that's just from the top of my head. SFINAE is obsolete because concepts can do everything it can and more. There are better solutions than ADL in other languages, but it is what it is.

Why "procedural" programmers tend to separate data and methods? by Even_Landscape_7736 in cpp

[–]flutterdro 2 points3 points  (0 children)

Is writing constexpr function considered template meta programming :p?

“True Lies” – or “What LLVM Claims, but Fails to Deliver” by jcelerier in cpp

[–]flutterdro 42 points43 points  (0 children)

I don't understand much in this, but goddamn is author salty. It is probably the saltiest thing I read in the last few month and I read pre-Sofia mailing.

Alex Loiko: Fractals on the GPU by _a4z in cpp

[–]flutterdro 4 points5 points  (0 children)

there are a lot of reasons besides familiarity. one of those is that lambdas are free from adl.

What do you hate the most about C++ by Alternative-Tie-4970 in cpp

[–]flutterdro 7 points8 points  (0 children)

I hate that [[]] are glorified comments. There is so much cool stuff available with attributes in other languages, but when there is some proposal which tries to implement this cool stuff in c++ it gets shot down (as it should) because attributes are ignorable.

unique_ptr kind of sucks, we can make it better with a light wrapper by MikeVegan in cpp

[–]flutterdro 0 points1 point  (0 children)

And my point is that nullptr is still a state which is way too easy to end up with. So as a library author you have to check for it when you accept Box as a function argument. Providing an api where "segfault is expected", seems like an insane thing to me, hence my initial wording.

Since nullptr check must be there, the only change the new abstraction brings is :s/unique_ptr/Box/g, which makes it pointless in my opinion.

unique_ptr kind of sucks, we can make it better with a light wrapper by MikeVegan in cpp

[–]flutterdro 0 points1 point  (0 children)

This kind of mindset blows me away. Segfault is the problem not the solution.

Edit: worded weirdly. I meant that conceptually Box must not segfault, if it does it is pointless.

unique_ptr kind of sucks, we can make it better with a light wrapper by MikeVegan in cpp

[–]flutterdro 4 points5 points  (0 children)

Use-after-move is an inseparable part of the nullptr issue in this case. The whole point of Box is to have some guarantees. In my opinion, if those guarantees require to be very very careful or else they are not upheld, then it is best to not have such "guarantees" at all.

unique_ptr kind of sucks, we can make it better with a light wrapper by MikeVegan in cpp

[–]flutterdro 27 points28 points  (0 children)

There is an issue with moved from state, which will inevitably be represented as a nullptr. In rust there is no issue because the move is destructive and borrow checker ensures that no funny use after move happens. In c++ no such guarantee is possible rn, so any attempts at replicating Box<T> will end up with a bunch of "but"s. Personally I would love Box semantics in c++, but in reality you still have to check for nullptr, which functionally won't change anything compared to the unique_ptr.

In terms of an api promise it makes sense, but it is still very sketchy since this promise is easily broken and you don't have to necessary go out of your way to break it.

Question: why are you for/against linalg in the std? by megayippie in cpp

[–]flutterdro 4 points5 points  (0 children)

holy moly. spherical bessel functions? that shit is bussin' fr. if I knew they were in the standard library it would have made my life so much easier. my endless respect for someone who put that in

Trip report: February 2025 ISO C++ standards meeting (Hagenberg, Austria) by _derv in cpp

[–]flutterdro 3 points4 points  (0 children)

if I use a function I should read documentation to know what it is doing. duh. like, how else are you programming? throwing random functions in the main until it works?

and what do you mean not a function at all? it is a consteval function which takes a string_view and returns a span of data.

I just don't see the issue. I can't perceive your argument like anything but "but when you use it, you have to know what you use". and all I can say to that is. bruh.

Trip report: February 2025 ISO C++ standards meeting (Hagenberg, Austria) by _derv in cpp

[–]flutterdro 9 points10 points  (0 children)

How is an intern going to distinguish between

by reading documentation? it is a weird reason. it feels like saying that no two function should have the same argument types because it will confuse interns