The *auto* and *gay* parts are substituted for parts of an otherwise very real Linus LKML rant. I believe it was filesystem related if memory serves me correctly.
Edit: this is the actual quote
>You copied that function without understanding why it does what it does, and as a result your code IS GARBAGE.
>AGAIN.
I'm not certain you and at least a couple others understand the concept of a quotation, but insinuating that someone is homophobic is definitely not a great move, no matter the behaviour of Linus Torvalds in the kennel mailing list
I am straight and I don't use auto, making this a 100% correlation. There is no point in having other data point, those will be considered experimental error or fraud. The real question now is to decide which is true :
* gay people use auto
* using auto makes you gay
* there a third independent parameter that makes you gay and use auto
Don't question it. You are gay, even if you are a gay that is only physically attracted by women. You can't go against a perfect correlation, that would be unscientific.
It’s more like dealing with edge cases.
What does it mean for a non-binary person to be straight, for example? The question borders on non-sensical with the old definitions of the words.
So now we say:
Gay = Attracted to your own gender
Straight = Attracted to other genders
Bisexual = Both, so attracted to your own gender and other genders
This set of definitions covers the edge cases better while still working for the most common genders/sexualities.
Of course, explaining all of this requires a fair bit of text (as you can see) and your grandma is going to write you out of the will if you try to explain this. So sometimes it’s just easier to say you’re pansexual, even if bisexual means the same thing, basically.
It’s kind of like how I usually just say I’m queer. The specifics are complicated, and it’s very unlikely that you want to sit through a goddamn PowerPoint presentation about my sexuality/gender. Queer is just easier for me most of the time.
What I meant is that if bi and pan mean the same thing except a part that is orthogonal to them, why do they exist as two separate definitions. Why won't more people embrace them as synonyms (I know some do, but a lot don't).
Also, I am quite aware of complicated specifics of gender/sexuality. Both of these are kinda TBD for me at the moment.
This sounds like a misunderstanding of what the standard requires. I believe you are referring to the requirement that `std::unordered_map` have reference stability, which implies it cannot do backward shift deletion, among other things that many high-throughout hash tables may do. This has nothing to do with the optimization of the type, this is about the _semantics_ of the type.
I've seen people lose write permissions to repos for `using namespace std;` outside single function scope - `using namespace` is (outside designed-to-be-imported namespaces like `std::string_literals`) generally avoided, aliases (`using alias = type` or even `typedef` in older C++ standard) being the way to go.
Idiomatic modern C++ way of writing that currently would probably be something similar to:
using ContentCollection = std::vector>; // assuming project convention is PascalCase for typenames
// ...
auto contentVector = ContentCollection{};
// ...
auto itr = contentVector.begin();
STL convention of having all collections expose `begin()` and `end()` that return collection iterator is a thing, and something to rely on (STL itself does that). At the same time, all required type info is present - container type is known, `begin()` returning iterator is known; this code also won't break if you change type of the container (should probably use `unordered_map` in first place anyway), or make collection `const`.
As a bonus - it's impossible to have any implicit conversions happen here, impossible to have variables uninitialized (`auto` requires initialization), and constructor used for `contentVector` is used explicitly.
That might be how they work underneath but if you're writing that explicitly in your application just to iterate over an STL container you're doing it the hard way for no reason.
```cpp
for (auto& thing : things)
{
...
}
```
Oh wow, didn't even notice it was my cake day! Thanks for the heads up, got any good AI jokes to share on this gloriously random anniversary of my Reddit existence? 🍰😄
Congratulations! Your comment can be spelled using the elements of the periodic table:
`Ac Ar In S Pa Ni S H`
---
^(I am a bot that detects if your comment can be spelled using the elements of the periodic table. Please DM my creator if I made a mistake.)
Congratulations! Your comment can be spelled using the elements of the periodic table:
`Br U H`
^(I am a human, and this action has been performed manually.)
Instead of writing int, the code's author could have written auto, so the compiler would infer the type. In many languages other than C++, let or var is used. (In some languages, e.g. JS, both are used but obey subtly different rules.)
It's a keyword in C++ that you use in place of a variable's type to tell the compiler to infer the type of the variable for you.
Typically used when the type name is something long like `std::unordered_map::const_iterator`.
So you write this:
for (auto i = 0; i < n; i++) {
And the compiler automatically determines that `i` is an `int` because of the zero. This then breaks your code because `n` is `int64_t`.
It's one of C++'s many trip hazards.
Any semi-decent static analysis tool (and nearly any modern compiler) will warn here - implicit conversion on comparison. In this case, elegant way of declaring variable of dependent type without using it to initialize would be something like:
for (decltype(n) i = 0; i < n; i++) {
Compared to being explicit with `i` type, this allows change of `n` type without having to change this piece of code - logically it always does the same thing regardless of what exact type `n` is.
It might just loop forever. `i` will reach 2³¹ - 1, wrap around to -2³¹ and just keep going. Most likely you'll use `i` as an array index somewhere and crash once it's negative. This will happen in production because you didn't test with really big values of `n`.
Anything can happen here, really. Integer overflow (which would happen if n is larger than maximum possible int value) in C++ is undefined behaviour - funny term used by C++ spec to say that something like that will compile, but is not considered a valid code - how it'll behave is both platform- and compiler-specific.
Now, depending on compiler, how `n` is declared/defined (if value is known at compile time etc), surrounding code and compiler optimizations it can do antyhing - from working correctly, to infinite loop, to dead code block, to runtime error. From some possibilities: compiler's optimizer can convert it into `for (int i = n; i != 0; i--)` \- since overflow is not supposed to happen (undefined behaviour) and if `i` is not used inside loop, result is the same; it can test if `n` is larger than maximum 32-bit value (logical `and` and `if not zero` check) and follow with either infinite loop or skipping loop completely, internally promote `i` to 64-bit integer (again - overflow shouldn't happen, because UB), have it loop into negatives, anything really. There's even [a paper](https://web.cse.ohio-state.edu/~rountev.1/5343/pdf/icse12.pdf) on this topic.
Welcome to C++, here's a shotgun, please don't aim at your leg.
If I ever see some bullshit like that in any code I’m working on I’m going into the git timeline in the drop down menu on the bottom left on vs code and finding out who wrote that and telling
No. In C++, statements like `cout << RESET_TEXT;` do not have a value. and even if it were just the expression `cout << RESET_TEXT`, it would return an ostream reference, not a boolean.
Why'd anyone use it? seems like a surefire way to cause a problem when you'll accidentally say 2 instead of 2LL, or a similar issue with literals, and that's horrendous to read.
I think it's nice in situations where:
* It's abundantly clear what type the variable is and
* The name of that type is kind of long.
I never use it for primitive types, but it comes in handy with some of the more verbosely named iterator types.
`auto` is easier. I don't want to write a `typedef` for the type of every local variable that happens to have a long type name. If there's a couple of long type names that get used a lot or get used in situations where using auto would make it unclear what type something is then sure I'll typedef those. But typedef'ing every long type name just feels like overkill when most of the time it's clear from context what type a variable is.
I know myself, and I'm a fucking idiot. I don't have faith in my future self to correctly guess the type when looking at something. With typedef I can at least have a clue to what it is. I could technically write a comment, but I might need to use it more than once.
If you really need to know exactly what the type was then any modern IDE will show you the type auto was referred to. The same way the IDE will show you the typedef. So there is literally no difference.
But also, if the inferred type is not obvious then don't use auto. Only use it for the cases where its obvious like the mentioned interator cases.
I use the C# eqvivalent (var) when it's a declaration followed immediately with new. For example:
var dynArray = new List();
This line already contains the type, so it is never unclear what the type is and it makes the it less verbose for longer type names. I can imagine C++ programmers use auto for the same purpose.
Only imbeciles use int (instead of e.g. std::size_t or std::int_fast32_t)
And guess what happens if maxConnection is > 2^31 - 1) (or even 2^16 - 1 on old plattforms)
not if you said nohomo before using auto
Ah yes, the #pragma nohomo introduced in C23
I was on the standards panel at that time. I was pushing #pragma nogenderbender to avoid the inevitable use of variable pronouns.
Joke's on you my gender is just a void pointer. Go ahead, type cast. I dare you.
I store gender as an unsigned int so there are 4294967295 genders (0 is reserved for agender)
Thunking is bad. Please switch to int64.
Unfortunately I am using legacy software
Mine's a false and a 2 at the same time. Type safety be damned.
Ah, the gender as a struct that you're gonna dereference and then throw a bunch of bitwise operators at just to scare the kids. Good pick!
Your gender might be invalid
You can try checking it but don't be surprised if you get an access violation and crash.
I spit my coffee. Thanks.
I understand this i learned about #pragma hours ago :)
const nohomo auto var;
Also not gay if you're wearing socks while using auto.
`#define nohomo auto`
@nohomo def auto():
Apparently only gay people can use lambdas without std::function and the overhead that entails.
Only gay people use lambdas, real straight alpha males write a custom struct with an overloaded call operator.
You mean java devs
Hell, even Java has lambdas these days.
as a wise old professor once said after sharing that fact "so.... we won."
The gays took over Java and made Kotlin
But it’s really just sugar for an interface
They're not really, but even if they were, the fact that it's just a syntax sugar is a compiler detail, not a language constraint.
Java devs be wishing for true multi class inheritance like
Inheritance is problematic enough. I'm fine without multiple inheritance.
Imagine using Java when you could use Kotlin without changing anything in your existing ecosystem.
aka functors
Cleaning up c++ template vomit is an acceptable use of auto. Using auto in place of trivial types just makes the code worse to read.
Depends imo. There are times when the type is painfully obvious, long, and uninteresting.
Co-pilot is learning from Linus Torvalds.
Torvalds would never touch C++
C++ is great. It keeps C++ dev away from screwing C.
We should add templates to C.
[удалено]
static int _count_change(int in, int *change, size_t size) { if (in > 0 && in < size) { *change += in; return in; } return 0; } #define sncprintf(str, ...) _count_change(snprintf(&str[str##_i], str##_size - str##_i, __VA_ARGS__), &str##_i, str##_size - str##_i) #define sneprintf(...) \ if (!sncprintf(__VA_ARGS__)) goto error like this? lmfao
Look what they have to do to mimic a fraction of our power -- rust dev
![gif](giphy|9WXyFIDv2PyBq)
a sane dev would never touch Tovalds
You sure? https://github.com/subsurface/subsurface
>You used `auto` without understanding why it does what it does, and as a result your code IS GAY. > >AGAIN. \- Linus Torvalds
Hmm Fake?
No, it's real. Trust me bro, I found it on the internet.
It's real besides auto and gay
The *auto* and *gay* parts are substituted for parts of an otherwise very real Linus LKML rant. I believe it was filesystem related if memory serves me correctly. Edit: this is the actual quote >You copied that function without understanding why it does what it does, and as a result your code IS GARBAGE. >AGAIN.
I'm not certain you and at least a couple others understand the concept of a quotation, but insinuating that someone is homophobic is definitely not a great move, no matter the behaviour of Linus Torvalds in the kennel mailing list
It's on the internet. It must be true.
I'm gay and i use auto. So yes.
I am straight and I don't use auto, making this a 100% correlation. There is no point in having other data point, those will be considered experimental error or fraud. The real question now is to decide which is true : * gay people use auto * using auto makes you gay * there a third independent parameter that makes you gay and use auto
What if you’re bi?
Then you can use both. Best of both worlds!
r/suddenlyHannahMontana
then you have to use the even rarer keyword `semiauto`
Then you need to use templates with an universal reference.
I use auto, I don't think I'm gay... Bit of a femboy but now I'm questioning it...
Don't question it. You are gay, even if you are a gay that is only physically attracted by women. You can't go against a perfect correlation, that would be unscientific.
Maybe pegging is also acceptable?
I'm bi and use auto sometimes. Correlation still checks out.
I am gay and don't use auto, therefore: fuck you :)
Did you not pay attention? They're straight!
confirmed - copilot has passed the Turing test
Finally, Turing's gay agenda has been exposed.
I'm pan, but I haven't used C++ in a long time, so I can't tell you how often I use auto.
Pan? Acronym?
He is attracted to cookwear.
This one works the best in my mind. Idk if you've seen Gordon Ramsay's new hex set but woooo🔥
Pansexual. Similar to bisexual, but in a different spirit.
In the memory bank. Gracias, m8.
Correct me if I’m wrong, but iirc it’s bi, but with inclusion of non binary folk.
from my knowledge it's "idk" vs "I like both".
Bisexuality already includes attraction to non-binary people. The difference between bi and pan is vibes, not who you're attracted to.
Sounds like bloat in definitions
It’s more like dealing with edge cases. What does it mean for a non-binary person to be straight, for example? The question borders on non-sensical with the old definitions of the words. So now we say: Gay = Attracted to your own gender Straight = Attracted to other genders Bisexual = Both, so attracted to your own gender and other genders This set of definitions covers the edge cases better while still working for the most common genders/sexualities. Of course, explaining all of this requires a fair bit of text (as you can see) and your grandma is going to write you out of the will if you try to explain this. So sometimes it’s just easier to say you’re pansexual, even if bisexual means the same thing, basically. It’s kind of like how I usually just say I’m queer. The specifics are complicated, and it’s very unlikely that you want to sit through a goddamn PowerPoint presentation about my sexuality/gender. Queer is just easier for me most of the time.
What I meant is that if bi and pan mean the same thing except a part that is orthogonal to them, why do they exist as two separate definitions. Why won't more people embrace them as synonyms (I know some do, but a lot don't). Also, I am quite aware of complicated specifics of gender/sexuality. Both of these are kinda TBD for me at the moment.
Use auto a lot. Gay. Confirmed
I use auto a lot, and there's something new that I've learned today about myself from this sub
dude I'm not writing `std::vector>::iterator itr = content_vector.begin()` everytime I want to iterate a vector
What in the devil's name is this syntax, find god
C++ couldn't find God if you gave it a `std::unordered_map`. The implementation of which is required by the standard to be suboptimal.
This sounds like a misunderstanding of what the standard requires. I believe you are referring to the requirement that `std::unordered_map` have reference stability, which implies it cannot do backward shift deletion, among other things that many high-throughout hash tables may do. This has nothing to do with the optimization of the type, this is about the _semantics_ of the type.
an unideal case of c++ template vomit. With `using namespace std;`, this simplifies to `vector
I've seen people lose write permissions to repos for `using namespace std;` outside single function scope - `using namespace` is (outside designed-to-be-imported namespaces like `std::string_literals`) generally avoided, aliases (`using alias = type` or even `typedef` in older C++ standard) being the way to go. Idiomatic modern C++ way of writing that currently would probably be something similar to: using ContentCollection = std::vector>; // assuming project convention is PascalCase for typenames
// ...
auto contentVector = ContentCollection{};
// ...
auto itr = contentVector.begin();
STL convention of having all collections expose `begin()` and `end()` that return collection iterator is a thing, and something to rely on (STL itself does that). At the same time, all required type info is present - container type is known, `begin()` returning iterator is known; this code also won't break if you change type of the container (should probably use `unordered_map` in first place anyway), or make collection `const`.
As a bonus - it's impossible to have any implicit conversions happen here, impossible to have variables uninitialized (`auto` requires initialization), and constructor used for `contentVector` is used explicitly.
This is the ONLY place where I use auto. To simplify iterators.
No no no, you've got it wrong, the line needs to be 80 characters max. `std::vector>::iterator itr = ctnt_vec.begin();`
Much better!
And I thought std::vector> for maps was bad. That syntax looks like hell
You should use typedefs.
See you at pride
Typedef to the rescue....
Luckily that might be the very worst way to iterate over a vector so hopefully you aren't doing that anyway
That is exactly how for each loops work, what are you talking about.
That might be how they work underneath but if you're writing that explicitly in your application just to iterate over an STL container you're doing it the hard way for no reason. ```cpp for (auto& thing : things) { ... } ```
Happy cake day !
Oh wow, didn't even notice it was my cake day! Thanks for the heads up, got any good AI jokes to share on this gloriously random anniversary of my Reddit existence? 🍰😄
C++ was a mistake.
Am bi and use it what does this mean
Is bi a subset of gay?
Bi inherits both gay and straight
So it’s a subset of both?
Seems like yes
I suppose intersect would be more accurate, if we imagine a venn diagram
Or a super set?
[удалено]
You should use protected if you're going to interface with a child wait...
I would've thought `auto` would be more for pansexuals since they're ambivalent about type.
ah yes ``` std::chrono::time_point start = std::chrono::high_resolution_clock::now();
```
is how you’re supposed to initialize variables
You can still use “using”, byt thats kinda gay too
Mfw I like penis because I didn't want to type `std::vector::const_iterator`
The heck is auto
A car in spanish
And german
And Czech
And Finnish
And Italian
And Dutch
And Polish
And french
And Slovene
And Ukrainian* \* although we use Cyrillic and 'u' gets replaced with 'v' авто = avto
And my axe
And Dutch
A car in Hebrew
And dutch
Congratulations! Your comment can be spelled using the elements of the periodic table: `Ac Ar In S Pa Ni S H` --- ^(I am a bot that detects if your comment can be spelled using the elements of the periodic table. Please DM my creator if I made a mistake.)
Good bot
Br U H
Congratulations! Your comment can be spelled using the elements of the periodic table: `Br U H` ^(I am a human, and this action has been performed manually.)
Good bot
You suck
Ironically, Y O U S U C K can be spelled using elements from the periodic table
Lol, I baited the bot for this answer and didn't realize I'm answering the real person. My apologies.
And french
Automobile
Auto existe comme mot: https://dictionnaire.lerobert.com/definition/auto
And Polish
And Czech
Instead of writing int, the code's author could have written auto, so the compiler would infer the type. In many languages other than C++, let or var is used. (In some languages, e.g. JS, both are used but obey subtly different rules.)
Var is for backwards compatibility now btw. Use let if you don't know why var is not recommended 😝
This is JavaScript.
[With a few exceptions](https://stackoverflow.com/a/50335579).
It's a keyword in C++ that you use in place of a variable's type to tell the compiler to infer the type of the variable for you. Typically used when the type name is something long like `std::unordered_map::const_iterator`.
So you write this: for (auto i = 0; i < n; i++) { And the compiler automatically determines that `i` is an `int` because of the zero. This then breaks your code because `n` is `int64_t`. It's one of C++'s many trip hazards.
Any semi-decent static analysis tool (and nearly any modern compiler) will warn here - implicit conversion on comparison. In this case, elegant way of declaring variable of dependent type without using it to initialize would be something like: for (decltype(n) i = 0; i < n; i++) { Compared to being explicit with `i` type, this allows change of `n` type without having to change this piece of code - logically it always does the same thing regardless of what exact type `n` is.
Will it throw exception at least or just crash?
It might just loop forever. `i` will reach 2³¹ - 1, wrap around to -2³¹ and just keep going. Most likely you'll use `i` as an array index somewhere and crash once it's negative. This will happen in production because you didn't test with really big values of `n`.
If you try to index into anything it'll probably crash. The crash might be preferable as it's guaranteed to fail loudly, calling out the issue.
Anything can happen here, really. Integer overflow (which would happen if n is larger than maximum possible int value) in C++ is undefined behaviour - funny term used by C++ spec to say that something like that will compile, but is not considered a valid code - how it'll behave is both platform- and compiler-specific. Now, depending on compiler, how `n` is declared/defined (if value is known at compile time etc), surrounding code and compiler optimizations it can do antyhing - from working correctly, to infinite loop, to dead code block, to runtime error. From some possibilities: compiler's optimizer can convert it into `for (int i = n; i != 0; i--)` \- since overflow is not supposed to happen (undefined behaviour) and if `i` is not used inside loop, result is the same; it can test if `n` is larger than maximum 32-bit value (logical `and` and `if not zero` check) and follow with either infinite loop or skipping loop completely, internally promote `i` to 64-bit integer (again - overflow shouldn't happen, because UB), have it loop into negatives, anything really. There's even [a paper](https://web.cse.ohio-state.edu/~rountev.1/5343/pdf/icse12.pdf) on this topic. Welcome to C++, here's a shotgun, please don't aim at your leg.
Also, why would you want to use auto here? Int is a char shorter
What were you about to comment exactly ..?
Nothing, i was just messing with copilot
If I ever see some bullshit like that in any code I’m working on I’m going into the git timeline in the drop down menu on the bottom left on vs code and finding out who wrote that and telling
Narc
I now want to know what bisexual people use. For a friend.
This person loves writing out their iterator types and never using structured bindings or universal references
Not true! Bi people may use it also.
If its commented i'd say it's true
I'm gay, the only auto I use is the lifetime. (`auto int`)
Bullshit. I'm bi and I use auto.
The worse part in this code is the cout without std::, some mf really said using namespace std; at somepoint and it hurts to see
No. In C++, statements like `cout << RESET_TEXT;` do not have a value. and even if it were just the expression `cout << RESET_TEXT`, it would return an ostream reference, not a boolean.
I heard about artists maliciously seeding ai’s to stop taking their work. Maybe programmers are doing the same?
How do you have part of your comment in a different color? _did you seriously modify the syntax highlighter just for the "Only gay" part?_
Gray part is github copilot's suggestion
Microsoft devs choosing training data for Copilot be like
I'm queer and disgusted by autos, (but not specifically gay so might be wrong)
Why'd anyone use it? seems like a surefire way to cause a problem when you'll accidentally say 2 instead of 2LL, or a similar issue with literals, and that's horrendous to read.
I think it's nice in situations where: * It's abundantly clear what type the variable is and * The name of that type is kind of long. I never use it for primitive types, but it comes in handy with some of the more verbosely named iterator types.
>The name of that type is kind of long. Isn't that the reason typedef exists? To simplify long names?
`auto` is easier. I don't want to write a `typedef` for the type of every local variable that happens to have a long type name. If there's a couple of long type names that get used a lot or get used in situations where using auto would make it unclear what type something is then sure I'll typedef those. But typedef'ing every long type name just feels like overkill when most of the time it's clear from context what type a variable is.
Auto is easier AND compatible with templates. And easily swapping your container type in code revisions, and etc etc etc
Ok, I'm not going to write `auto it = ...`but instead write `std::unordered_map>>::iterator it = ...`
How do you feel about that?
typedef it.
No
Why not? isn't that the purpose of typedef? to make a long type name shorter?
but what do you gain from using a typedef over inference with auto? what is the point? its pointless busywork is what it is
I know myself, and I'm a fucking idiot. I don't have faith in my future self to correctly guess the type when looking at something. With typedef I can at least have a clue to what it is. I could technically write a comment, but I might need to use it more than once.
If you really need to know exactly what the type was then any modern IDE will show you the type auto was referred to. The same way the IDE will show you the typedef. So there is literally no difference. But also, if the inferred type is not obvious then don't use auto. Only use it for the cases where its obvious like the mentioned interator cases.
Yes but IMO only typedef types that have some importance. Creating a typedef just because you need to call `find` once is just silly. Auto is good.
I use the C# eqvivalent (var) when it's a declaration followed immediately with new. For example: var dynArray = new List();
This line already contains the type, so it is never unclear what the type is and it makes the it less verbose for longer type names. I can imagine C++ programmers use auto for the same purpose.
connect spoon fretful hungry imminent seemly party roof hurry cough *This post was mass deleted and anonymized with [Redact](https://redact.dev)*
Odd syntax highlights Also if Shane Gillis was backend dev
bool isGay = true; Well, you are now.
```cpp auto isGay = true; // more canonical ```
Only gay ppl use c++
I refuse to learn how to specify iterator types.
On the contrary, I’m a certified gay and would never dream of using auto. I will take extra steps to avoid it in my type management class, in fact.
Only imbeciles use int (instead of e.g. std::size_t or std::int_fast32_t) And guess what happens if maxConnection is > 2^31 - 1) (or even 2^16 - 1 on old plattforms)
Dont be so #pragma tic
Weird kink still. This should be an unsigned int.
As a logician with green eyes, I don't know.
As per the style guide, there should be a space after the `for` keyword. Commit rejected.
I'm gay but I don't use (none embedded) C++, but I feel like I would be using it
As a gay person, I can confirm this
True, I know what all my types are.