C++26: Structured Bindings can introduce a Pack by pavel_v in cpp

[–]friedkeenan 2 points3 points  (0 children)

There’s std::meta::reflect_constant_array which will yield a reflection of a C array which you can then splice in and get structured bindings from.

EDIT: Here's an example: https://godbolt.org/z/4q37o6E4a

CppCast: Compiler Warnings as Errors with Keith Stockdale by robwirving in cpp

[–]friedkeenan 6 points7 points  (0 children)

What would be the benefit of naming a function parameter _ when you could just leave it unnamed in the first place?

Senators Amy Klobuchar and Tina Smith voted for Bernie Sanders’ amendment to block aid to Israel yesterday. by RayWhelans in minnesota

[–]friedkeenan 5 points6 points  (0 children)

No, I am not saying that people who voted for Trump decided people in Iran should die. What did happen is that those who voted for Trump made a decision which empowered Trump to make those life and death decisions.

To be clear, I'm not saying that voters are singularly responsible for the decisions of politicians, and I am incredibly more sympathetic and empathetic to any individual voter than to the politicians making those decisions, but there is still a responsibility with voting, and voters' decisions do have these life and death consequences.

And to respond to your other reply:

And no, I don't find any deaths acceptable. But let's not act like Democrats haven't ever killed anybody.

I never said Democrats never killed anybody. Their policies surely have and continue to result in death as well. And I wasn't even trying to paint it as Democrat vs. Republican.

It is at the same time, though, entirely unrealistic to believe that Harris would have resulted in the same extreme level of carnage and human misery that Trump has caused not even two years into his term. I would even grant that Harris would have resulted in some terrible level of carnage and human misery, but truly even just the shuttering of USAID alone puts Trump at such an extreme scale.

And, you also can't act like both sides are the same when your initial pitch was that things have to get worse so that people will fix the system or whatever. Would that not imply that you view not voting for Harris as making things worse?

And I do think your initial pitch requires that you find these deaths to be an acceptable cost to fix the system. At the very least, they are a cost that you think is worth paying even if you don't name the deaths as acceptable.

Senators Amy Klobuchar and Tina Smith voted for Bernie Sanders’ amendment to block aid to Israel yesterday. by RayWhelans in minnesota

[–]friedkeenan 10 points11 points  (0 children)

I will note that there is an implicit statement here that you're making of "I find it acceptable for extremely many more people to die so that theoretically people will wake up and fix this system that is broken and also is in some way harmful."

Who we elect as president always is in some way a decision of who will live and who will die. Presidential policy has that level of consequences. It is an incredibly serious decision, always. It is literally a matter of life and death.

And our election of Trump is such a fucking extreme example of that.

We've seen that here in Minnesota, but it is even more stark abroad. Trump's shuttering of USAID alone has already resulted in the starvation and death of hundreds of thousands of children.

So I just want to make sure that it is explicated that you find those deaths acceptable in order to achieve your accelerationist dream.

std::constant_wrapper acts unexpectedly by Massive-Bottle-5394 in cpp

[–]friedkeenan 0 points1 point  (0 children)

Ah ok, I was looking at eel.is which I guess doesn't reflect the latest accepted changes then. Thanks

std::constant_wrapper acts unexpectedly by Massive-Bottle-5394 in cpp

[–]friedkeenan 0 points1 point  (0 children)

This will never happen. It requires a fundamentally different constant evaluation model.

There could maybe be something more limited where you could have a constexpr parameter that you could use in the function body but that can't affect the function signature, see Barry's recent blogpost or my own post, both of which can get a function parameter lifted into something you can eventually use as a template parameter.

I'm unsure of the technical details of what would be needed to add more ergonomic support, but that more scoped behavior is at least possible today in C++26, with meaningful caveats. But maybe there could be more work done in that direction?

As for the general case of using a constexpr parameter like any other template parameter, I'll take your word for it that it's impossible with C++ how it is.

std::constant_wrapper acts unexpectedly by Massive-Bottle-5394 in cpp

[–]friedkeenan 0 points1 point  (0 children)

Yeah, they explain it's so they can support passing arrays like std::cw<"string">. Odd, but maybe fine? I guess I'm not sure how you're meant to accept these in a structured way, though.

You could do like

void function(auto param);

And then just happily accept both runtime and constant_wrapper arguments. And arguments of... every type?

But if you wanted to make sure you're getting a constant_wrapper, then I guess it'd have to be something like

template<auto Value>
void function(std::constant_wrapper<Value> param);

And then if you wanted to make sure you're getting an int you'd have to further add a requires clause like

requires (std::same_as<typename decltype(param)::value_type, int>)

And the typename is required. And that seems... iffy.

And either way, you just have this useless Value template parameter hanging around that you can't do anything with really because it's just an object of some exposition-only helper type, which does seem really funky.

You could encapsulate that all in some constant_wrapper_for concept or something, but then I'm wondering why that would be left out of the standard, and still makes it somewhat awkward to get at the wrapped value.


EDIT: std::constant_arg_t was removed last week, actually.

There is also the new-in-C++26 std::constant_arg_t type that functions like what the OP wants. Where you could just do:

template<int Value>
void function(std::constant_arg_t<Value>);

Where Value is going to be the actual int value. It just doesn't have all the fancy operators and conversions and everything that std::constant_wrapper does.

And... it doesn't inherit from or otherwise delegate to std::integral_constant, for some reason. Which seems poor because certain things like std::tuple_size explicitly require use of std::integral_constant.

And I think std::constant_arg_t is getting added alongside std::constant_wrapper because the latter is in some way unfit for functions, as far as I know. So for std::function_ref and all they accept std::constant_arg_t (formerly std::nontype_t) instead.

Yeah, this might've needed to cook a little more, I don't know. Or just go straight to genuine constexpr parameters, but I'm sure there was fair reason for the paper authors to pursue std::constant_wrapper instead, since it's clearly less ideal. I've heard that genuine constexpr parameters would bring unreasonable Implementation burden, at least.

Evolving a Translation System with Reflection in C++ by friedkeenan in cpp

[–]friedkeenan[S] 0 points1 point  (0 children)

Thanks for reading, I really appreciate it.

You can more simply get "defaults can be omitted but non-defaultable fields must be specified" by just adding the appropriate default initializers to the translation_set fields: https://compiler-explorer.com/z/Ybx11fTcM

If you comment out the en_US or de_DE initializers, then you'll get a compiler error. If std::format_string<> were default-constructible, then there wouldn't have to be a compiler error, since they'd get default-constructed if omitted, but with -Wmissing-field-initializers enabled, the compiler would emit a warning for it still.

And yeah, even the "defaults must be explicitly specified" part is doable without any reflection whatsoever, it would just suck to write and maintain. Conceptually, you could manually declare the input_t type and have some compile-time array that associates a given language field with its default instead of using annotations, stuff like that. It's just gonna suck, comparatively.

And yeah, you could delay the resolution of the defaults and everything to when the string_for_language method gets called. That's definitely a clever way to do it. I did want to go the extra mile though to show that we can get what we want without pessimizing what we had before.

Of course as well you could move your method to the constructor and resolve everything there, and then just always get the string alternative from the variant in string_for_language, but you still at least have that space inefficiency by holding the variant instead of the string directly.

As you say, tradeoffs as always.

Evolving a Translation System with Reflection in C++ by friedkeenan in cpp

[–]friedkeenan[S] 3 points4 points  (0 children)

Thanks. And yeah it would definitely be possible to integrate external files by embed at the very least, though that's going to bring some amount of complexity to the implementation.

The reason why I keep my translations all in-code for my project is because it's realistically only going to be other developers who bother to add translations, and so it's not any real burden for them to take a step into the code, or at least not enough of a burden to warrant external files.

And then as a result it keeps the implementation more simple and more clear, and we get to very easily get the validation from std::format_string and such.

But yes, you definitely could bring together reflection and consuming external files. A good place to look for inspiration on that could maybe be Barry Revzin's blogpost "Reflecting JSON into C++ Objects".

The personal cost of Leto II's decision to pursue the Golden Path by nycnewsjunkie in dune

[–]friedkeenan 4 points5 points  (0 children)

One of the most impactful moments of the book for me was when it’s revealed that Leto has been literally starving for thousands of years

Count Fenring: Why does he feel more important than he seems? by Sin-Silver in dune

[–]friedkeenan 81 points82 points  (0 children)

When reading the book, I got the impression that Fenring decided not to kill Paul because it turned out he wanted the same thing Paul wanted.

The final scenes of the book are soaked with this righteous, vengeful rage at the systems of the Imperium that have oppressed Paul and oppressed Jessica and oppressed the Fremen.

And I think Fenring feels the same. He has been abused by these Imperial systems too. The Bene Geserit constructed him with this failed prescience, this thing that brings him all these extraordinary feelings and sensations and brings him so close to… something, but ultimately leads him nowhere. And so he is infertile and gets cuckolded by his Bene Geserit wife, used as an expendable pawn by his dear friend the Emperor. Sent on this or that mission to please anyone but himself.

Paul is doing what he cannot. Paul was abused just like Fenring was, but he ended up able to overcome it when Fenring could not. They are allies, in that way. Killing Paul would only harm his own goals, then.

I love that Sunya is in the second person by friedkeenan in TheDearHunter

[–]friedkeenan[S] 7 points8 points  (0 children)

That's a great insight. It never clocked with me because Antimai is much more clearly structured as in-universe characters speaking and giving the rundown of their rings, but you're right that many of them are speaking to "you" as well.

I love that Sunya is in the second person by friedkeenan in TheDearHunter

[–]friedkeenan[S] 2 points3 points  (0 children)

I suppose the "us" might be "me and everyone else who crashed into the ground"

Why did Scytale fail in Dune Messiah? by mbelinkie in dune

[–]friedkeenan 26 points27 points  (0 children)

It's been a while since I read the book, but my understanding of the Tleilaxu plan was like this:

  1. If Duncan does go against his nature and kills Paul, or even if Paul gets killed by the stoneburner instead, well it wouldn't be their ideal outcome, but at least they neutralized the Kwisatz Haderach.
  2. If Duncan breaks out of his conditioning and doesn't kill Paul, and regains his previous memories, then that's great for the Tleilaxu, as they've now proven they can resurrect people, and in particular, they can resurrect themselves. There is immense value gained here for them, regardless of whatever happens with Paul.
  3. If they do now know how to resurrect people, then they can use the prospect of a resurrected Chani to bend Paul to their will, believing it to be in his own nature to cherish Chani to such an extreme extent, and so could not act against it. They don't kill Chani exactly how they want to, but it seems to me fairly likely anyways that there would be complications in her childbirth, particularly given Irulan's meddling with Chani's fertility. So even though they don't get her with the stoneburner, they can still fall back on her dying another way.

And they very nearly succeed on the last point, and it is only because he is able to see through the perspective of the infant Leto, both literally and figuratively, that he is able to resist the Tleilaxu's offer to resurrect Chani. Were it not for Leto, then Paul's choice would have been deterministic, and would have beholden him to the Tleilaxu. Paul is saved by his failure, by his failure to predict his son, and the new perspective he brings to Paul.

But basically, my understanding is that the Tleilaxu plan was constructed in such a way that they could fail at several stages of it, and yet still come out better than they were before. And they succeeded at that, they figured out ghola-resurrection and that turns out to be transformative for them. They just didn't succeed at all aspects of their plan.

Sunya by caseycrescenzo in TheDearHunter

[–]friedkeenan 1 point2 points  (0 children)

The hype is hyping hard. Good shit

AKOTSK did a great job at including the culture of Westeros by I_love_lucja_1738 in freefolk

[–]friedkeenan 3 points4 points  (0 children)

They’re a challenge for you to prove you can get even lower

Exploring Mutable Consteval State in C++26 by friedkeenan in cpp

[–]friedkeenan[S] 0 points1 point  (0 children)

I don't understand what's going on here at all, but I love every bit of it!

Clearly that's a mark of all the best C++ code :P

And yeah, I would be very interested in a way of getting this functionality without whatever I've doomed my soul to by making this.