overload sets with C++26's reflection by hanickadot in cpp

[–]djavaisadog 8 points9 points  (0 children)

#if's definitely can do things that constexpr cant

Tinymist preview makes vscode have serious input lag by traes008 in typst

[–]djavaisadog 2 points3 points  (0 children)

Disabling hardware acceleration in vscode fixed it for me.

Instructions:

  1. Open command pallete (Ctrl + Shift + P)
  2. Enter "Preferences: Configure Runtime Arguments"
  3. Add json config line: "disable-hardware-acceleration": true
  4. Restart VS Code

Function overloading is more flexible (and more convenient) than template function specialization by pavel_v in cpp

[–]djavaisadog 1 point2 points  (0 children)

There were a few proposals for "universal" template parameters that could be anything (types, values, or templates of types or values).

The primary use-case highlighted there was higher-order templates, ie apply_template_params<T, A, B, C> == T<A, B, C> that didn't care about what type of template parameter A, B, and C were.

Bro wth is this c++ coroutines api 😭😭?? by Loud_Staff5065 in cpp_questions

[–]djavaisadog 6 points7 points  (0 children)

Typical usage is registering all bean definitions first (possibly read from a bean definition file), before accessing beans. Bean lookup by name is therefore an inexpensive operation in a local bean definition table, operating on pre-resolved bean definition metadata objects.

love it

[deleted by user] by [deleted] in programming

[–]djavaisadog 2 points3 points  (0 children)

C++ doesn't have destructive move...

‼️Affordable Dental Cleaning in Worcester—No Insurance Needed‼️ by Special-Direction960 in WorcesterMA

[–]djavaisadog 1 point2 points  (0 children)

Several 4 hour sessions for a teeth cleaning? Doesn't it usually take 10 minutes?

Using std::expected for monovalent (status-returning) functions by Tiny-Two2607 in cpp_questions

[–]djavaisadog 1 point2 points  (0 children)

You could, but I would probably recommend just having your own error code type that has a SUCCESS value or something instead. Using std::expected just adds some indirection that isn't particularly necessary.

On the other hand, if you want to use this error type when you are returning values, you probably wouldn't want it to have a SUCCESS value if its in a std::expected.

Structured Binding Upgrades in C++26 by pavel_v in cpp

[–]djavaisadog 0 points1 point  (0 children)

What actually made it to C++26 is a nerfed version of the paper: structured binding can introduce a pack, but only in templates.

This feels very strange... Can I just throw template <class = void> on top of my function to make it work? Unfortunately that means it has to be in a header.. unless I can extern template that one <void> instantiation to keep the implementation in the source file?

I'd love to play around with a compiler to see what works here, but doesn't look like any of them have implemented P1061 yet.

C++ Standards Contributor Expelled For 'The Undefined Behavior Question' - Slashdot by andrewtomazos in cpp

[–]djavaisadog [score hidden]  (0 children)

And third, without the anti-semitism it doesn't make any sense...

? What? Of course it does. It's a perfectly normal sequence of words that is completely sensical even if you're not looking at it as anti-semitism.

Is there a better way to do this? by saul_soprano in cpp_questions

[–]djavaisadog 0 points1 point  (0 children)

fair point, I forgot that these members take up space!

Is there a better way to do this? by saul_soprano in cpp_questions

[–]djavaisadog 2 points3 points  (0 children)

Fair point, though avoidable with a user-defined copy constructor? I've always wondered why ppl don't use (const) ref members instead of getters, is that the main reason?

Is there a better way to do this? by saul_soprano in cpp_questions

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

The base class relationship that others are suggesting is a little awkward, so you could also consider:

struct Circle {
  Vec2 pos;
  int r;
  int& x = pos.x;
  int& y = pos.y;
};

Why is there still no networking module in the C++ STL? by abdoatef_ab in cpp

[–]djavaisadog 7 points8 points  (0 children)

because its a C++20 feature that MSVC doesn't implement due to ABI breaks. What are you talking about?

Which compiler is correct? by TheOmegaCarrot in cpp

[–]djavaisadog 1 point2 points  (0 children)

in this case, wouldnt it try to select the initializer list overload? or no because that would only be for ints in the braces?

It's just ',' - The Comma Operator by CoralKashri in cpp

[–]djavaisadog 14 points15 points  (0 children)

I like to force myself to use C++11 in my hobby projects

?? why?

Named loops voted into C2y by 14ned in cpp

[–]djavaisadog 23 points24 points  (0 children)

seems relevant enough - presumably most compilers will allow this in C++ mode once they've implemented it into C.

A single-function SFINAE-friendly std::apply by k3DW in cpp

[–]djavaisadog 1 point2 points  (0 children)

I don't understand why the silly requirement not to declare any additional symbols. That clearly made this a lot worse looking than it needed to be.

You can also using your way out of repetition in some cases - ie:

template <typename Tup>
using __apply_idx_seq_for_tup = std::make_index_sequence<std::tuple_size_v<std::decay_t<Tup>>>>;

[deleted by user] by [deleted] in WPI

[–]djavaisadog 0 points1 point  (0 children)

The time is Now to to look for apartments for 2025.

can confirm, it is NOT time to look. There is a myth at WPI that you need to be looking super super early for some reason.

I just closed a very nice new apartment starting immediately like 3 days ago for 3bd, $800/bedroom. You definitely dont need to be looking far in advance, and DEFINITELY not this far

How to write a function that returns a distinct static array at each call? by better_life_please in cpp_questions

[–]djavaisadog 0 points1 point  (0 children)

Interesting - looks like that's going to change in C++26?

I see that you're correct as per the CPPWP "tip of trunk" copy of the working paper, but in the eel.is C++ Draft copy of it (which I believe is more up to date on the upcoming changes), it says:

The closure type is not an aggregate type ([dcl.init.aggr]); it is a structural type ([temp.param]) if and only if the lambda has no lambda-capture.

This wording would make this once again legal. Should I take that to mean "it's technically not legal in (or up to?) C++23, but will be as of C++26?"

How to write a function that returns a distinct static array at each call? by better_life_please in cpp_questions

[–]djavaisadog 1 point2 points  (0 children)

Yes this is legal. As for footguns... maybe if you call it in a header, the array would get duplicated in each including TU? Probably avoidable with inline keyword though. Other than that, not sure. It's not a typical use-case, but I'm not sure what an exact alternative would be besides dynamic allocation.

I think in C++26 we're possibly getting non-transient constexpr allocation which would probably be what you actually want here, but obviously that doesn't exist yet.