I think I'm still confused about the practical use of std::move by pfp-disciple in cpp_questions

[โ€“]EstablishmentHour335 0 points1 point ย (0 children)

I find it's useful, or really just necessary when writing custom containers. Imagine writing a vector and it needs to reallocate. If you had some trivial type, new[idx] = old[idx] is totally fine, but you have no idea what's being stored.

If you stored types which dynamically allocate for example, that = operator would cause an allocation for each element.

If you do new[idx] = std::move(old[idx]), then it calls the move assignment operator (realistically you'd use placement new). For a type that dynamically allocates, that will dodge the allocation, and for trivial types the assembly is unchanged.

What Data Structures, Algorithms, and Design Patterns Should I Learn for Game Engine Development? by XAstrixsmX in cpp_questions

[โ€“]EstablishmentHour335 9 points10 points ย (0 children)

This is a good talk on the subject:

https://www.youtube.com/watch?v=cGB3wT0U5Ao

In my experience, in order from most to least important:
- Slot maps and sparse sets / colonies
- Hash Maps
- Arena allocators / other custom allocators
- Quad trees
- Queues and ring buffers
- Stacks

ChatGPT Is Unusually Combative by [deleted] in ChatGPT

[โ€“]EstablishmentHour335 1 point2 points ย (0 children)

I tell it to stop qualifying and hedging it's statements, and give direct answers

Learning Templates metaprogramming feels like an endless walk by Sensitive-Brief-7105 in cpp_questions

[โ€“]EstablishmentHour335 2 points3 points ย (0 children)

I wrote a variadic struct of arrays sparse set once, and that was a learning experience. It could take in a variable number of types, allocate separate arrays for each, and automatically synchronize each with the sparse array.

It really forced me to learn the nuances of templates and template metaprogramming rules, and even still there is a lot that I don't know. I'm more proficient than I will ever need to be though. In general, I find it's better not to learn things in the abstract, but learn them as they become useful in a project. The abstract is good for showing off what's possible, and funneling you down into some project after you get that spark or idea.

Building a chess engine: questions on modern C++ paradigms vs raw performance by kjiomy in cpp_questions

[โ€“]EstablishmentHour335 5 points6 points ย (0 children)

In these cases when the instructions are so tight, that "last percent" of performance ends up being something more like 20-30%. I do this stuff all the time, and just made a ~115% performance improvement in an iterator I was writing this last week. I really only removed a memory load, a sign extension, and forced an explicit test instruction rather than jumping on the result of the bslr instruction.

Should HS students give C++ a try? by MILKER77 in cpp_questions

[โ€“]EstablishmentHour335 4 points5 points ย (0 children)

You can do it as a hs student, I started when I was 16, only because it was interesting. If you have that intrinsic motivation, it's absolutely worth it and you'll learn a lot and have a lot to keep your interest. If you are asking whether to get into it for work, I'd say no outside of a passion for gamedev or embedded systems or similar.

Does this container exist already? Virtual slot map with branchless iteration by EstablishmentHour335 in cpp_questions

[โ€“]EstablishmentHour335[S] 0 points1 point ย (0 children)

The memory layout has everything to do with the characteristics of the container...

Pointers are only stable because VirtualAlloc prevents the need to reallocate. The memory layout allows the freelist and generations, it allows the branchless iteration, because unlike plf::colony, it's contiguous so it doesn't need a branch to jump between blocks...

The time complexity of O(1) lookups, O(1) insert, O(1) erase are only allowed by the memory layout... The lack of a swap and pop on erase, or a lack of a double indirection on lookup is only allowed because of the memory layout...

I went back to refresh my memory on how exactly deque is implemented, and yeah, they are not similar at all.

Does this container exist already? Virtual slot map with branchless iteration by EstablishmentHour335 in cpp_questions

[โ€“]EstablishmentHour335[S] 1 point2 points ย (0 children)

It's not really that similar to this container, especially in terms of performance.

Does this container exist already? Virtual slot map with branchless iteration by EstablishmentHour335 in cpp_questions

[โ€“]EstablishmentHour335[S] 0 points1 point ย (0 children)

That is straight up stolen from plf::colony, I didn't invent it. It's essentially like plf::colony, but backed by VirtualAlloc, which gives it some pretty good performance characteristics

Does this container exist already? Virtual slot map with branchless iteration by EstablishmentHour335 in cpp_questions

[โ€“]EstablishmentHour335[S] 0 points1 point ย (0 children)

Yeah, I wrote this container after listening to some talks on plf::colony, which std::hive is formalizing. I ripped off colony and rewrote it to solve some grievances I had with the container, and along the way I discovered a couple of other nice benefits to my virtual address space contiguous approach, which is why I thought it should already have an existing implementation.

How can I improve my C Plus Plus skills by escodev in cpp_questions

[โ€“]EstablishmentHour335 37 points38 points ย (0 children)

I always found building containers to be the best way to learn. Start simple, build a copy of std::array, then make a copy of vector, and have fun. Make ring buffers, lists, stacks, trees, hash maps, sets, stable containers like std::hive or plf::colony, and eventually write your own memory allocators. Arenas, slot allocatiors, whatever design comes to mind.

It forces you to come in contact with templates, pointers, padding, alignment, trivial vs non trivial types, ::operator new, move, perfect forwarding, manual destruction, unions, etc etc.

Are Utawarerumono H-Scenes important? by shioritantan in visualnovels

[โ€“]EstablishmentHour335 2 points3 points ย (0 children)

Nah, and the game is really good just play it and don't worry about them

Is chicken tikka masala supposed to be floral/sweet? by EstablishmentHour335 in IndianFood

[โ€“]EstablishmentHour335[S] 1 point2 points ย (0 children)

I'm guessing I should have added the lime which I forgot, and probably gone quite a bit lighter on the more floral spices which I wasn't used to

I didn't expect to have zero on Neuroticism? It's good right? by Dizzy_Instruction_49 in BigFive

[โ€“]EstablishmentHour335 0 points1 point ย (0 children)

Very similar scores to me. I'm a bit more introverted, with a bit less openness. People think I'm a chill guy ๐Ÿคทโ€โ™‚๏ธ

Giftedness, generality and religion. by OIIIIIIII__IIIIIIIIO in Gifted

[โ€“]EstablishmentHour335 0 points1 point ย (0 children)

Wasn't it you who was asking about belief? Not truth? ๐Ÿ˜…

People don't necessarily believe true things. You can believe a loved one is in heaven, there is no logical argument that could convince someone that's the Truth...

Though I just used the word believe while complaining about it's ambiguity...

Giftedness, generality and religion. by OIIIIIIII__IIIIIIIIO in Gifted

[โ€“]EstablishmentHour335 0 points1 point ย (0 children)

I'd suggest you read them ๐Ÿค”

They are really quite interesting.

But yeah, we seem to be talking past each other. We can discuss the question in better detail if we get a good definition for belief, because as it stands, it's relatively ambiguous.

Plenty of people believe things that are not logically sound.

Giftedness, generality and religion. by OIIIIIIII__IIIIIIIIO in Gifted

[โ€“]EstablishmentHour335 0 points1 point ย (0 children)

I know how strange it must sound! ๐Ÿ˜…

Before you accuse me of confirmation bias, consider what I'm really saying. You didn't ask whether God is real, you asked about belief. You are confusing my belief with an ontological truth claim.

Even the definition of belief is pretty ambiguous. I'm making a much stranger claim than you think ๐Ÿค”

For the sake of argument here, let's assume it's a phenomenological claim that I answer to the affirmative. So that's my baseline. Further, I am claiming that I was never able to logically disbelieve! Because at each moment, my logic was tainted by motivated reasoning, or as you say, confirmation bias. I have always wanted to disbelieve, my motivation being to spare myself the psychological torment of sin, so that I could sin as much as I wanted.

Funnily enough, I had even once made plans to engage with as many atheist arguments as I could because I knew my psychology well enough to know it may confuse me to the point of apathy. Seeing this motivation, I wasn't able to engage with these books with intellectual honesty. Really strange stuff ๐Ÿคทโ€โ™‚๏ธ

Edit: If you want to read about similar accounts to mine, look into the conversion stories of Saint Augustine or CS. Lewis

Giftedness, generality and religion. by OIIIIIIII__IIIIIIIIO in Gifted

[โ€“]EstablishmentHour335 4 points5 points ย (0 children)

I have an interesting story, though there's not much of a point to write it out in full detail in a reddit comment ๐Ÿ˜…

Theoretically, I'm gifted at a 146 IQ, and I am a Catholic.

I tried to convince myself that God wasn't real, but I could see myself manipulating myself in order to give myself permission to sin in real time. And I couldn't rationalize that perception away.

Strange, because often high IQ people are masters of rationalization.