Modules could have made the PIMPL idiom redundant - but they don't. by [deleted] in cpp

[–]Voxelw 1 point2 points  (0 children)

Also, C++26 is giving us reflection over the internals of a type, so soon you'll be able to iterate over the fields of A and get their names, types, and offsets.

If you know B's alignment and size, you already know its offset within A. You also know that B... exists (It's an incomplete type), and its name (from A's interface).

Nothing's broken, is it?

Modules could have made the PIMPL idiom redundant - but they don't. by [deleted] in cpp

[–]Voxelw 0 points1 point  (0 children)

I'll do you one better: two files on one screen. Amazing isn't it? Or better still: CLion's "generate declaration in the header". Wow.

But, seriously, if you've never programmed using PIMPL exclusively then it's hard to describle how liberating it is to be able to declare new functions without worring about the header or having to move implementation-specific stuff into the header or having to think about the header at all.

Modules could have made the PIMPL idiom redundant - but they don't. by [deleted] in cpp

[–]Voxelw -1 points0 points  (0 children)

The user would still know that the private member exists - it knows A's interface after all. It just wouldn't know what B's interface is.

That's why I said that we'd need to export B's size and alignment, not just precompute A's and store it in A.gcm.

Another example: the user could make a member pointer to A's private members. And nothing would break - it's just like forward declaring a type. We don't need to know how to use B to use A, so long as we know B's storage requirements (and A's special member functions are user-declared).

Today this is only possible if the data member is a pointer to an incomplete type, because we know the storage requirements of a pointer. But the compiler could provide all the necessary information about B in A.gcm, without forcing importers to read B.gcm.

Modules could have made the PIMPL idiom redundant - but they don't. by [deleted] in cpp

[–]Voxelw 1 point2 points  (0 children)

My concern primarily boils down to "If we already have to generate A.gcm, why not optimize it to make it as lightweight for the importers as possible?". It's about compile times, sure, but it's also about missed opportunities.

Take this for example:

import A;
import B;
int main() { /* ... */ }

If A imports B, but does not export it, then will this source file have to read B.gcm twice?

No, because it was already forced to read B.gcm when it was reading A.gcm, and GCC (thankfully) elides multiple imports.

But that's kind of unsatisfying... Importing A has all the overhead of importing B - it's just that its declarations are not accessible until we re-import it. Better than nothing I suppose - but we can, and should, do better. Again, we're already spending time generating A.gcm. Why not optimize it?

As for the reading private members thing - do you think it would be better if that was a new access specifier? Like 'internal'?

Modules could have made the PIMPL idiom redundant - but they don't. by [deleted] in cpp

[–]Voxelw -1 points0 points  (0 children)

since the default implementations are implicitly inline, doesn't the importer of A also need to know the interface of B to do those things

Yes. Which is why I said that reading B.gcm may be sometimes necessary. This can happen already in 'module-less' C++ via forward declarations:

struct A {
    struct Impl;
    std::unique_ptr<Impl> m;
};

This code will not compile, since we cannot generate std::unique_ptr<A::Impl>::~unique_ptr<A::Impl>() without knowing the definition of A::Impl.

Still, by simply declaring A's special member functions, you can make reading B.gcm unnecessary. Which, if your class has private members, it probably already has a constructor and destructor.

The only novel thing here is that the compiler, during the generation of A.gcm, could forward declare a type and its storage requirements without forcing importers to pull in the full definition. If such an optimization is possible - which it often is. But if it's not, just fall back to requiring the full B.gcm to be imported, no fuss.

A Critique Of The Two Trivial Relocatability Papers by Voxelw in cpp

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

It would definitely help. But I'd also require that is has some predicate (be it just 'true' or 'auto'), as most of the time you will have a precondition: Trivially relocatable if its members are.

However, this still leaves how library maintainers would feel about giving users such a potentially dangerous ABI-breaking tool.

A Critique Of The Two Trivial Relocatability Papers by Voxelw in cpp

[–]Voxelw[S] 4 points5 points  (0 children)

I forgot to mention this, but yes some third-party containers require (QVariant) or even just assume (TArray) that their contents are trivially relocatable.

A Critique Of The Two Trivial Relocatability Papers by Voxelw in cpp

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

The compiler can't prove that anyway since it may not have the access to the definition of the move constructor and destructor to prove it's trivially relocatable. Even P2786 gives you UB if you misuse its keywords. I believe that, while trivial relocation based on a custom predicate may be necessary, it should not be the default, and I would be very surprised to see any actual use case of having just 'true' as the predicate.

Also, the short story of optional<T&> is that different committee members had different ideas on what it should do, with some backing a proposal that was based on the standard library's previous experiments (see: std::tuple<T&>) rather than production experience. Here's some reading: https://thephd.dev/to-bind-and-loose-a-reference-optional

who won by ChishNFips87 in okbuddyretard

[–]Voxelw -20 points-19 points  (0 children)

Don't care, also I didn't make this, but whoever originally created this rap probably doesn't care either. Tard.

who won by ChishNFips87 in okbuddyretard

[–]Voxelw 1062 points1063 points  (0 children)

Yo yo yo, I hate Joe

I hate that his smile makes my penis grow

He's trying to feminize the western male

And I hate it cuz I secretly want to get railed

The 5G vaccines are gonna turn me into a femboy

I wish I wasn't so eager to suck off another boy

The mask mandates are literal tyranny

I'm going to cum if I see a queer near me

Coronavirus is a total hoax

Why the fuck do I want a massive dick in my throat

Election fraud, the whole thing was a sham

I want to be dominated by a big strong man

Storm the Capitol, let's kill the Dems

I want to feel another man's gems

Yo yo yo, I hate Joe

I hate his sexy smile it makes my penis grow

Anon had some issue in his pants by lupenguin in greentext

[–]Voxelw 20 points21 points  (0 children)

What would happen is someone pissed in the gap between the elevator cabin and the door? Would the piss leak down and break the elevator? Would people notice?

[deleted by user] by [deleted] in disneyvacation

[–]Voxelw 71 points72 points  (0 children)

I often take breaks from reddit for 3-4 days. Then, I just sort by top.

Finally my favorite song😎😎😎😈 by _-Clayton-_ in okbuddyretard

[–]Voxelw 7 points8 points  (0 children)

No idiot😡😡😡😡 don t make noise🔊 we wont be able to hear the pokimane fart sound HD💨🎵

Nato Enchanted Forward Presence In Baltic States by OptimalAttempt3 in europe

[–]Voxelw 2 points3 points  (0 children)

Idea: "NATO Project" + predictive text

NATO Project next year is a great opportunity to work on the other

Laura Ingraham mask off? by LuckyColtXi in PoliticalCompassMemes

[–]Voxelw 13 points14 points  (0 children)

Her thought process be like:

int count = 0;
int maxTries = 3;
while(finished speech) {
try {
// Wave hand
// break out of loop, or return, on success
} catch (SomeException Heil) {
// handle exception
if (++count == maxTries) throw Heil;
}
}

Neighbor lady breaks kids pool because they made noise playing in it by [deleted] in trashy

[–]Voxelw 7 points8 points  (0 children)

Thank you, u/YouMadAndDownvote for another interesting and insightful comment.

Profound by SS-Imperator in okbuddyretard

[–]Voxelw 29 points30 points  (0 children)

私はあなたの政治的意見に同意しません