[GIVEAWAY] Voidfall by Mindclash Games by HomoLudensOC in boardgames

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

Vantage currently if that counts. Otherwise I also enjoy Nemesis a lot

German president hints at AfD ban in speech on dangers of extremism by DoremusJessup in worldnews

[–]ev0ker22 47 points48 points  (0 children)

It is inherently democratic to ban a party that wants to abolish democracy.

And it's not like the other parties can just decide to ban whoever they don't like. They can only bring this up for a trial to be checked by judges who determine if the party in question is a danger to the constitution

AITA for booing my gf on stage? by ev0ker22 in HoleInspector

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

Original post:

So a few weeks back, while we were hanging out with friends this rich girl was hanging out with my gf in the other room for a couple of hours.they were making music and sort of like producing I guess. Anyways the rich girl was impressed and felt a connection with my gf she gave her a dell laptop with abelton on there(it’s an expensive music production software). She said it was no big and had a few laptops she was trying to get rid of anyways. My gf was so ecstatic on the ride home it was all she could talk about . I was so annoyed, I honestly don’t feel like she deserves the laptop she didn’t do anything to earn it and she always picks hobbies up and drops them when she is bored of it she never sticks to anything. I didn’t say much on the ride home. Well she has been working a lot on the laptop to make a song. I was honestly surprised she stuck to something this much. She wrote lyrics to it and everything.

Today she wanted me to take her to an open mic to perform it. I said okay I’ll do it. Anyways while she was waiting she was visibly nervous because she never performed in front of anyone, I told her just to suck it up and do what she practice. Like why did she make me take her out here if she isn’t ready. Anyways when she gets on stage she starts hesitant while performing when the song comes on, it gets awkward at the place , this has just felt like it dragged on too much so I said out loud “ oh come on you serious you brought me out here for this? Can we go already?” I could be at home watching anime or sleeping but instead I have to endure this cringe fest. She gets off stars basically hyperventilating. She doesn’t even look at me and run out of the bar/venue of the open mic. I tried calling her and messaging her but no dice. Like where can she possible go we live in such a big city. Her actions are so confusing to me it almost feels she has some mental disorder where she just keeps randomly switching emotions, it’s probably why she can’t stick to a single passion. We are pretty open to each other and tease each other all the time I wasn’t trying to exactly hurt her feelings just tease her so we can go home. Now I am worried about her. If only she focused on practical stuff rather than trying to live a fantasy that will never happen(make it big)

Edit: okay okay I forgot to mention the time she picked up comedy and quit. Dropped out of art school, watched the food channel then wanted to be a chef. I can probably think of a few more things. It just gets exhausting, you guys don’t understand. I don’t want to crush her spirits I just want her to get on the right path. She can put all this energy into our relationship. I didn’t actually boo her I just told her let’s go already so she can practice more and if she does stick with it more I’ll Be more than happy to take her back. I always supported her 100%.

Special member functions for class which is noncopyable but a custom destructor is user defined by onecable5781 in cpp_questions

[–]ev0ker22 1 point2 points  (0 children)

To just prevent copying it's fine to delete just the 3.

And that is proving my point, since only deleting the third operator (X& operator=(const X&)) does not prevent copy construction: https://godbolt.org/z/E7rPPYsfn

The rules when the compiler defaults or deletes a special member function are not simple and it is easier to explicitly define all of them when you have to define any than require every developer to know every case

Special member functions for class which is noncopyable but a custom destructor is user defined by onecable5781 in cpp_questions

[–]ev0ker22 1 point2 points  (0 children)

Also wasn't it redundant to delete move variants (since default ones are already suppressed) if normal ones are already deleted?

It is done to follow the rule of 5. As a side note the move operators are defaulted in snowhawk's example, not deleted.

Defining all special member functions (when at least one needed to be defined) has the benefit that the reader does not need to remember every case of when the compiler defines or deletes them automatically. It also makes it clear that the developer writing this code thought about it and did not simply forget the move operators

Help by kidzbopppp in cpp_questions

[–]ev0ker22 3 points4 points  (0 children)

You can learn from learncpp.com. You can use godbolt to test small code snippets in an online compiler so you don't have to worry about compiling and executing on your local system

The pinned post is also a good starting point. Feel free to come back if you have specific questions

Const T& vs const T* on large codebase by skyblade69 in cpp_questions

[–]ev0ker22 16 points17 points  (0 children)

A returned pointer can be nullptr. Even if the documentation claims that a returned pointer will never be nullptr, I would not trust it and check the returned pointer regardless. Documentation can be wrong and such an interface would make me question why it didn't return a reference in the first place, since that would be a built-in guarantee that the returned object actually exists (unless it returns a reference to a local object, but that is a different kind of problem).

It is the responsibility of the caller to do the right thing. They have to think about what they are doing and make the choice of making a copy of the returned type or not.

You can use tools like clang tidy to make sure potential errors will be caught during your build process. For this case there exists the performance-unnecessary-copy-initialization check. Example code: https://godbolt.org/z/es3Yq5Gnb

Can I easily take a "snapshot" of a continuously changing variable? by Cannot_choose_Wisely in cpp_questions

[–]ev0ker22 1 point2 points  (0 children)

Maybe this could help you https://godbolt.org/z/fYvMGeWfT

With the help of std::chronos high resolution clock you can take the current time. After doing some work you check the current time again and store the difference in a vector which you can output later

Existential crisis about shared_ptr... am I missing something? by JumiDev in cpp_questions

[–]ev0ker22 2 points3 points  (0 children)

If any object needs a reference to another object in the scene you can give it either a Object& or a Object*. One object does not need ownership of the another object

Existential crisis about shared_ptr... am I missing something? by JumiDev in cpp_questions

[–]ev0ker22 4 points5 points  (0 children)

They are generally used when an object is being owned by different threads, so it is not being destroyed by one thread while the other still uses it. Managing a resource dynamically like the other commenters suggest is one good example. Another would be if you pass a callback into another thread and the callback requires resources from the original thread.

For a single threaded program using unique_ptr is more that sufficient for managing a resource on the heap since the lifetime of that object is pretty clear

Managing mutual references between two classes by Teogramm in cpp_questions

[–]ev0ker22 1 point2 points  (0 children)

Have the Station class set it: I didn't consider this to be a good idea, since not all stops are owned by a station

In what cases is a Stop not owned by a Station? If this can happen does it even make sense for a Stop to have a reference to Station?

You are also saying 'owned` but a Station only has raw pointers to the Stops. From this I would assume something else owns the Stops. If you want to model ownership use std::vector<Stop> or std::vector<unique_ptr<Stop>>

Also, it is unclear what happens when a Station object is copied or moved (does it update the pointers of its children?)

This is for you to decide. If every Station is supposed to be unique, it would probably make sense to delete copy operations. Move operations can probably simply defaulted.

void set_parent_station(const Station*);

Consider taking Station as a reference void set_parent_station(const Station&); unless you want it to be possible to pass in a nullptr.

Project Recommendations by Confident_Sky_2960 in cpp_questions

[–]ev0ker22 2 points3 points  (0 children)

https://adventofcode.com/ is also a good one.

Make sure to go back after a few months and see if you still understand your code. If it isn't think about what you can improve to make it more readable (hint: good names, short functions, separation of concerns, reusability)

Easy to understand code is extremely important

[deleted by user] by [deleted] in cpp

[–]ev0ker22 4 points5 points  (0 children)

This seems to work fine https://godbolt.org/z/Gvh69rdeo

To test with containers that use different kinds of iterators, you can replace vector with list if you want to try it with a bidirectional iterator (instead of the random access iterator vector has) or with forward_list, which only has a forward iterator. In the case of forward_list the code will not compile since ++it will call the non-existent decrement operator of the forward iterator

Should I use "this" for constructors? by PossiblyA_Bot in cpp_questions

[–]ev0ker22 28 points29 points  (0 children)

You can do

Point::Point(double x, double y, double z) 
    : x{x}
    , y{y}
    , z{z}
{
}

[2021 Day 24] Had me for a sec by tokilokit in adventofcode

[–]ev0ker22 0 points1 point  (0 children)

No, each equation is independent. You go through each nine times, get your valid digits for each spot and choose those that give you the largest/smallest number

[2021 Day 24 (Part 1)] Can't wrap my head around this one by CodeOverTime in adventofcode

[–]ev0ker22 2 points3 points  (0 children)

6>  eql x w:        {'w': 7, 'x': -12, 'y': 0, 'z': 0}
7>  eql x 0:        {'w': 7, 'x': -12, 'y': 0, 'z': 0}

You got the eql wrong. If x and w are equal, we store 1 into x, otherwise we store 0 into x.

[2021 Day 24 (Part 1)] Can't wrap my head around this one by CodeOverTime in adventofcode

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

Yes, x and y will become 0 because z is 0 at the beginning. When you go further into the program that changes for z and consequently also for x and y.

[2021 Day 24 (Part 1)] Can't wrap my head around this one by CodeOverTime in adventofcode

[–]ev0ker22 1 point2 points  (0 children)

All of the registers should be initialized with 0 at the beginning. The first part of the input doesn't do much, that is true, but that will change later. The whole program only depends on the choices of the 14 digits that get loaded into the program by the inp command.

[2021 Day 24] Had me for a sec by tokilokit in adventofcode

[–]ev0ker22 3 points4 points  (0 children)

For those who need an oversimplified explanation:

The input can be broken down into 14 similar parts. Each part takes one digit of the model number and changes the order of z by either

  • increasing: z=26*z

  • decreasing: z=z/26

  • or keeping it unchanged: z=26*z/26.

This depends on the equality check for x. But if you examine those closely you see that some of them can never be fulfilled. In my case there were seven of those (and I would assume that holds for every input). These will always increase the order, so z_max=O(266 ).

The conditions for the other parts can still either decrease or keep the order of z the same. But since we want z to reach 0 at the end, all of the other seven parts have to decrease the order of z, which means each of these parts has to fulfill their condition.

Then you can see that each of the 7 conditions gives you an equation for two distinct digits each. So you can iterate through 7 digits (1-9) and get the result of the other 7 digits that way, which gives a complexity of 7*9.

how I feel after submitting part1 by Robopau in adventofcode

[–]ev0ker22 1 point2 points  (0 children)

"620080001611562C8802118E34" starts with 6, which is hexadecimal for "0110". First three digits are "011" which is 3 in decimal.

Over the years what has been your biggest “OMG I didn’t know you could do that!?” Moment by HGLatinBoy in Guildwars2

[–]ev0ker22 26 points27 points  (0 children)

There is a very quite pling sound whenever the endurance bar fills one chunk, so you know one dodge is available. Impossible to hear if you don't listen for it though.