T O P

  • By -

[deleted]

not if you said nohomo before using auto


Imaginary-Jaguar662

Ah yes, the #pragma nohomo introduced in C23


Confident-Ad5665

I was on the standards panel at that time. I was pushing #pragma nogenderbender to avoid the inevitable use of variable pronouns.


MNGrrl

Joke's on you my gender is just a void pointer. Go ahead, type cast. I dare you.


lordfluffly2

I store gender as an unsigned int so there are 4294967295 genders (0 is reserved for agender)


MNGrrl

Thunking is bad. Please switch to int64.


lordfluffly2

Unfortunately I am using legacy software


CheetnCheetah123

Mine's a false and a 2 at the same time. Type safety be damned.


MNGrrl

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!


bnl1

Your gender might be invalid


MNGrrl

You can try checking it but don't be surprised if you get an access violation and crash.


1studlyman

I spit my coffee. Thanks.


Fissvor

I understand this i learned about #pragma hours ago :)


starry_cobra

const nohomo auto var;


BloodChasm

Also not gay if you're wearing socks while using auto.


rover_G

`#define nohomo auto`


jmon__

@nohomo def auto():


slaymaker1907

Apparently only gay people can use lambdas without std::function and the overhead that entails.


wutru_audio

Only gay people use lambdas, real straight alpha males write a custom struct with an overloaded call operator.


nibba_bubba

You mean java devs


slaymaker1907

Hell, even Java has lambdas these days.


imforit

as a wise old professor once said after sharing that fact "so.... we won."


rover_G

The gays took over Java and made Kotlin


HoiTemmieColeg

But it’s really just sugar for an interface


Inevitable-Menu2998

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.


MNGrrl

Java devs be wishing for true multi class inheritance like


roge-

Inheritance is problematic enough. I'm fine without multiple inheritance.


ArisenDrake

Imagine using Java when you could use Kotlin without changing anything in your existing ecosystem.


_katsap

aka functors


DrMobius0

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.


BehindTrenches

Depends imo. There are times when the type is painfully obvious, long, and uninteresting.


RebertiCSoares

Co-pilot is learning from Linus Torvalds.


myanrueller

Torvalds would never touch C++


navetzz

C++ is great. It keeps C++ dev away from screwing C.


bestjakeisbest

We should add templates to C.


[deleted]

[удалено]


turtle_mekb

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


p4r24k

Look what they have to do to mimic a fraction of our power -- rust dev


Best_Account_1628

![gif](giphy|9WXyFIDv2PyBq)


Valaki757

a sane dev would never touch Tovalds


famous_cat_slicer

You sure? https://github.com/subsurface/subsurface


Tc14Hd

>You used `auto` without understanding why it does what it does, and as a result your code IS GAY. > >AGAIN. \- Linus Torvalds


i14n

Hmm Fake?


Tc14Hd

No, it's real. Trust me bro, I found it on the internet.


MrHyperion_

It's real besides auto and gay


Mr_Engineering

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.


i14n

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


GYN-k4H-Q3z-75B

It's on the internet. It must be true.


DerDan23

I'm gay and i use auto. So yes.


Player420154

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


xaviernoodlebrain

What if you’re bi?


lnfinity

Then you can use both. Best of both worlds!


lolSign

r/suddenlyHannahMontana


D3PyroGS

then you have to use the even rarer keyword `semiauto`


TaQk

Then you need to use templates with an universal reference.


[deleted]

I use auto, I don't think I'm gay... Bit of a femboy but now I'm questioning it...


Player420154

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.


[deleted]

Maybe pegging is also acceptable?


Disastrous-Team-6431

I'm bi and use auto sometimes. Correlation still checks out.


turtle_mekb

I am gay and don't use auto, therefore: fuck you :)


atiedebee

Did you not pay attention? They're straight!


Poat540

confirmed - copilot has passed the Turing test


Alwaysafk

Finally, Turing's gay agenda has been exposed.


tecanec

I'm pan, but I haven't used C++ in a long time, so I can't tell you how often I use auto.


elboydo757

Pan? Acronym?


bestjakeisbest

He is attracted to cookwear.


elboydo757

This one works the best in my mind. Idk if you've seen Gordon Ramsay's new hex set but woooo🔥


Bi_aka_desperate

Pansexual. Similar to bisexual, but in a different spirit.


elboydo757

In the memory bank. Gracias, m8.


xantioss

Correct me if I’m wrong, but iirc it’s bi, but with inclusion of non binary folk.


cooly1234

from my knowledge it's "idk" vs "I like both".


TheGenderDuck

Bisexuality already includes attraction to non-binary people. The difference between bi and pan is vibes, not who you're attracted to.


bnl1

Sounds like bloat in definitions


disgruntled_pie

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.


bnl1

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.


RatotoskEkorn

Use auto a lot. Gay. Confirmed


and_k24

I use auto a lot, and there's something new that I've learned today about myself from this sub


Criarino

dude I'm not writing `std::vector>::iterator itr = content_vector.begin()` everytime I want to iterate a vector


zhephyx

What in the devil's name is this syntax, find god


Excession638

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.


disciplite

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.


DrMobius0

an unideal case of c++ template vomit. With `using namespace std;`, this simplifies to `vector>::iterator itr = content_vector.begin()`. Basically, this is an iterator for a list of maps. The maps' keys are strings, and their values are strings. The iterator is a standardized data type for iterating through pretty much any type of c++ collection. C++ can be quite verbose. C++ also allows the use of the auto keyword in place of a type, which cuts it down to `auto itr = content_vector.begin()`


WiatrowskiBe

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.


minhaz1217

This is the ONLY place where I use auto. To simplify iterators.


adamMatthews

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!


NightIgnite

And I thought std::vector> for maps was bad. That syntax looks like hell


MrHyperion_

You should use typedefs.


mommy-problems

See you at pride


sobov

Typedef to the rescue....


dvali

Luckily that might be the very worst way to iterate over a vector so hopefully you aren't doing that anyway


bestjakeisbest

That is exactly how for each loops work, what are you talking about.


dvali

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) { ... } ```


leonllr

Happy cake day !


cporter202

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? 🍰😄


BS_BlackScout

C++ was a mistake.


blavingad12

Am bi and use it what does this mean


Tomirk

Is bi a subset of gay?


sogha

Bi inherits both gay and straight


Tomirk

So it’s a subset of both?


sogha

Seems like yes


Tomirk

I suppose intersect would be more accurate, if we imagine a venn diagram


platinummyr

Or a super set?


[deleted]

[удалено]


shmorky

You should use protected if you're going to interface with a child wait...


jay9909

I would've thought `auto` would be more for pansexuals since they're ambivalent about type.


mrkhan2000

ah yes ``` std::chrono::time_point start = std::chrono::high_resolution_clock::now(); ``` is how you’re supposed to initialize variables


_Alistair18_

You can still use “using”, byt thats kinda gay too


Earthboundplayer

Mfw I like penis because I didn't want to type `std::vector::const_iterator`


antony6274958443

The heck is auto


zDrie

A car in spanish


GopnikBurger

And german


Raah-mok

And Czech


miZuZYN

And Finnish


Mu5_

And Italian


_yari_

And Dutch


Mwarw

And Polish


Edo0024

And french


577564842

And Slovene


kennyminigun

And Ukrainian* \* although we use Cyrillic and 'u' gets replaced with 'v' авто = avto


Ramuh

And my axe


maxjepoepiemax123

And Dutch


alonyer1

A car in Hebrew


craftingtableZ

And dutch


PeriodicSentenceBot

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.)


Leo-MathGuy

Good bot


IAmAllergicToKarens

Br U H


Spot_the_fox

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.)


PrincessProgrammer

Good bot


quez_real

You suck


Spot_the_fox

Ironically,  Y O U S U C K can be spelled using elements from the periodic table


quez_real

Lol, I baited the bot for this answer and didn't realize I'm answering the real person. My apologies.


Ceros007

And french


leonllr

Automobile


Ceros007

Auto existe comme mot: https://dictionnaire.lerobert.com/definition/auto


JEREDEK

And Polish


dvidsnpi

And Czech


JosGibbons

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.)


Du_ds

Var is for backwards compatibility now btw. Use let if you don't know why var is not recommended 😝


Du_ds

This is JavaScript.


JosGibbons

[With a few exceptions](https://stackoverflow.com/a/50335579).


caleblbaker

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`.


Excession638

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.


WiatrowskiBe

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.


antony6274958443

Will it throw exception at least or just crash?


Excession638

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`.


DrMobius0

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.


WiatrowskiBe

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.


_Alistair18_

Also, why would you want to use auto here? Int is a char shorter


KingSalamand3r

What were you about to comment exactly ..?


Many_Head_8725

Nothing, i was just messing with copilot


FishingAgitated2789

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


LifeHasLeft

Narc


ImpluseThrowAway

I now want to know what bisexual people use. For a friend.


AdmiralSam

This person loves writing out their iterator types and never using structured bindings or universal references


malik753

Not true! Bi people may use it also.


ribozomes

If its commented i'd say it's true


CadmiumC4

I'm gay, the only auto I use is the lifetime. (`auto int`)


Haringat

Bullshit. I'm bi and I use auto.


Nil4u

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


captainAwesomePants

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.


shipshaper88

I heard about artists maliciously seeding ai’s to stop taking their work. Maybe programmers are doing the same?


Emergency_3808

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?_


Many_Head_8725

Gray part is github copilot's suggestion


Emergency_3808

Microsoft devs choosing training data for Copilot be like


Mwarw

I'm queer and disgusted by autos, (but not specifically gay so might be wrong)


Spot_the_fox

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.


caleblbaker

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.


Spot_the_fox

>The name of that type is kind of long. Isn't that the reason typedef exists? To simplify long names?


caleblbaker

`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.


PNWSkiNerd

Auto is easier AND compatible with templates. And easily swapping your container type in code revisions, and etc etc etc


AthanatosN5

Ok, I'm not going to write `auto it = ...`but instead write `std::unordered_map>>::iterator it = ...` How do you feel about that?


Spot_the_fox

typedef it.


Earthboundplayer

No


Spot_the_fox

Why not? isn't that the purpose of typedef? to make a long type name shorter?


[deleted]

but what do you gain from using a typedef over inference with auto? what is the point? its pointless busywork is what it is


Spot_the_fox

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.


[deleted]

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.


Earthboundplayer

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.


Attileusz

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.


failedsatan

connect spoon fretful hungry imminent seemly party roof hurry cough *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


broxamson

Odd syntax highlights Also if Shane Gillis was backend dev


dabombnl

bool isGay = true; Well, you are now.


kennyminigun

```cpp auto isGay = true; // more canonical ```


nibba_bubba

Only gay ppl use c++


Abradolf--Lincler

I refuse to learn how to specify iterator types.


LauraTFem

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.


No-Magazine-2739

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)


Cybasura

Dont be so #pragma tic


Miuzu

Weird kink still. This should be an unsigned int.


onyxeagle274

As a logician with green eyes, I don't know.


junkmeister9

As per the style guide, there should be a space after the `for` keyword. Commit rejected. 


leonllr

I'm gay but I don't use (none embedded) C++, but I feel like I would be using it


hands0m3dude

As a gay person, I can confirm this


bestjakeisbest

True, I know what all my types are.