C++ library

> C++ library
> objects literally only exist on the heap
> yet every fucking function takes a reference
> *evetything *looks *like *this

what the fuck is it with cpp wankers
and their fucking reference obsession?

> const int& GetWidth () const

jesus christ

Attached: stroustrup-2011-why-cpp.png (359x539, 297K)

It isn't js

chi-in chi-out instead printf()
c++ /thread

Attached: aaa1.gif (500x213, 499K)

why would you ever return rvalue const reference

because values are an evil C thing
learn to program high level, sweetie

> objects literally only exist on the heap
not true;

this code allocate on the stack :
Nigger nigger(nigarg);

this one on the heap :
Nigger* nigger = new Nigger(nigargs);
delete nigger;

Pointers decay to references in C++ why the fuck are you doing *that?

You just use references in the function declaration and then you don't have to do any weird things in the code.
Something like this is much more typical:
bool some_function(const container &input_a, const container &input_b, container &output);

>> objects literally only exist on the heap
This is a good thing. With move semantics this is super efficient.

>> yet every fucking function takes a reference
References implicitly convert to pointers? Plus references allow you to take arguments by value

>> *evetything *looks *like *this
That's c

>what the fuck is it with cpp wankers and their fucking reference obsession?
References is what you mean to use most of the time when programming in any language, it's just that c++ actually allow you to express this manually, so that you don't have to rely on the compiler hopefully optimizing it for you

>> const int& GetWidth () const
What's wrong ?

>BOOHOO PROGRAMMERS ACTUALLY HAVE TO DO WORK INSTEAD OF RELYING ON WEAKASS NOOB GARBAGE LANGUAGES THAT GIVE PROGRAMMERS NEXT TO NO CONTROL OVER ANYTHING
C or get the fuck out.
>C IS BAD
You don't understand C.
>I UNDERSTAND C, C IS BAD
You don't understand C.

>LANGUAGES THAT GIVE PROGRAMMERS NEXT TO NO CONTROL OVER ANYTHING
C++ gives you a lot more control than with C. What are you talking about?

>this bait again
C does not fit into all niches, some people want to write highly abstract code that still compiles to high performance machine code, some people prefer reducing development time over program runtime. To think that there is a single language that can satisfy everyone's needs is insanity. Fuck off.

>two greentext arrows
>space after arrows
>reddit spacing

Attached: bet_youre_not_used_to_witty_filenames.png (497x513, 155K)

>reddit spacing
>markup
>"> "
go back

Attached: 7085c669.gif (237x240, 1.95M)

Imagine being THAT new

Are you fucking retarded? I was talking about one particular library, not C++ in general.

Wut? Of course they don't.

And this is how I know you don't understand C. If you really learn and understand C, you'll understand how fucking crippling and useless every single other language is and you won't even touch them.

so you're saying everyone who writes in any other language than C is wrong to code in that language?

> References implicitly convert to pointers?

Since when? Where the fuck did more than 1 moron in this thread got the idea that C++ somehow automatically converts pointers to references?

> That's c

lmao

> References is what you mean to use most of the time when programming in any language, it's just that c++ actually allow you to express this manually, so that you don't have to rely on the compiler hopefully optimizing it for you

Yeah, the problem is that in C++, you always have both pointers and references. Oh, and values too.

>no you don't REALLY understand C, you're wrong
>no I'm not telling you what it means to understand it
Do you know what the word "compromise" means?
Fuck off.

Anyone who doesn't write C is a poo in the loo

Must be subpar programmers using C++. I rarely need pointers in C++.

Yes.
>I want to stab you in the eyes!
>I don't want you to.
>How about one eye?
>NO!
>DO YOU KNOW WHAT THE WORD "COMPROMISE" MEANS?
You're probably a fucking Pybaby. You and your fucking garbage noob language can go fuck off.

The absolute strawman in this post is astounding. Wanna know how I can tell you've never actually worked in a real work environment?
Not everything in programming is related to purely what you can do in the language, you need to also consider things like time of development and bottlenecks not related to your cpu actually processing code, like disk/network IO. In those cases, writing your code in the fastest possible language isn't necessary, and instead you can focus on making your code more maintainable or easier to add features to. Relative to other languages, C is not one where developers can quickly create programs that do what they want, the number of details you need to remember to handle that other languages simply handle for you is higher, thus C is not a good choice in these types of cases.
Fuck off.

(Side note, sometimes I do wish things like python had actual pointer-like types instead of forcing you to use wrapper objects, it would be rather convenient. I'm not gonna go tear up my code base and rewrite it in C++ just so I can have it, though.)

The spaces come from OPs text, and clover makes the extra arrows. Honestly only newfags call out newfags anymore

>>Since when? Where the fuck did more than 1 moron in this thread got the idea that C++ somehow automatically converts pointers to references?
>Since when? Where the fuck did more than 1 moron in this thread got the idea that C++ somehow automatically converts pointers to references?

int a;
int* p = &a;


>> That's c
>lmao
Have you ever written any c? Even ctard agree that everything in c is a pointer (they just argue that that's okay because it's better)

>> References is what you mean to use most of the time when programming in any language, it's just that c++ actually allow you to express this manually, so that you don't have to rely on the compiler hopefully optimizing it for you
>Yeah, the problem is that in C++, you always have both pointers and references. Oh, and values too.
???

That's taking the address of a and assigning it to the pointer p. There is no reference in your example.

Somehow, the library designers must have gotten the memo that one should use references everywhere, but not that they should stop using the heap for everything.

If you really need stack allocated containers you can write your own allocator to allocate blocks on the stack and construct your containers directly in them. It's just not the typical use case for resizable containers for obvious reasons.

>stack allocated containers
Container classes should be stack objects with heap pointer properties.

The more I use C++, the more I realize that references are only good for operator overloading and only serve to obfuscate code elsewhere.

> int* p = &a;

Do you know what a C++ reference is? Go read like the first two pages from a cpp book.

I only use references for short-lived input arguments, little things like Rect, Point etc, to make it easy to create and pass them inline when needed.

I always make out args pointers, it's self-documenting. Long-living objects are passed by pointer as well (to signify that I'm not actually "sending" the object there, just offering a handle).

Const references on function parameters are useful.

That's not C++ that's Java++

in some cases using a ref for 64-bit objects or less (such as ints or floats) can actually be slower than just copying. const & is good practice if your tossing objects around though

the compiler will optimize out the ref

depends on the compiler. through visual studio, we got some weird results