Daily reminder that this is a valid C++ expression: 1[this]

Daily reminder that this is a valid C++ expression: 1[this]

Also, C++ thread.

Other urls found in this thread:

vc.gg/templeos/Terry A Davis Live Stream-xmB_VdDiLPA.mp4
cpp.sh/5uapd
cpp.sh/5w2su
cpp.sh/4rh4
cpp.sh/4banh
twitter.com/NSFWRedditVideo

So you can write a method which returns a pointer to the object following the current object if you have an array of them?

Genuinely amusing.

Obviously.
But why the fuck would you do that?

Just because C++ gives you the power to do stupid things doesn't mean you should.

...How does this get interpreted as that though? You index 1 with an object?

While we are at it:
int main() {
printf("WTF??!");
}


This prints "WTF|" in both C and C++ afaik.

In C, ptr[index] is little more than a macro for *(ptr+ index). You can exchange a pointer and an index when using subscript syntax and achieve the same thing.

Trigraphs are gone in C++17(?) so that should no longer happen.

1 gets converted to ptrdiff_t

take your POOlang to pajeet

c++ is for niggers

this

literally why?

niggers are too dumb to even understand C

vc.gg/templeos/Terry A Davis Live Stream-xmB_VdDiLPA.mp4

>method

method is just another word for member function. There's no point splitting hairs about terminology.

I don't see any advantage personally from using C over C++

Terry wrote his own C compiler, of course he thinks C++ is for niggers.

>of course terry runs ubuntu is for niggers

Simplicity is sometimes an advantage of its own. There isn't a single atom of C++ that can't be overloaded to mean something different to what you expected, and there's huge potential for some nightmarish scenarios because of that.

>reading c++ code
>having to think like a compiler
can autism levels reach that high?

>I don't see any advantage personally from using C over C++
kill you're self

ok

will do sir

Maybe it's a macro

delete this;

It's true. C++ is straight up unreadable. It took them one and a half decade to create a fucking half assed refactoring tool

this should have been a reference and not a pointer
prove me wrong

Yeah. You can overload the unary +. Have you ever seen unary + used in code?

>"C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C."

cpp.sh/5uapd

Why tho. The purpose of references is to avoid pointing to uninitialized/invalid memory.

>explicitly calling delete
You're doing it wrong.

this always points to initialized memory.

it's a "delet this" meme.

>this always points to initialized memory.
Not after you delet it.

Post yfw even Java has modules these days

>these days
this is what a bandwagoning retard looks like

S A L T Y
A
L
T
Y

Just like your mama.

>no return 0;

I don't think that works
cpp.sh/5w2su

Freed memory is not immediately overwritten.

ur mom is for niggers

FOUND THE
N I G G E R
I
G
G
E
R

> implying you need to

what you're tring to do is nonsensical
it can be done in multiple ways
you can have tags on objects to know if you've reached the end
you can pass the index value and the size as either variable or constant parameters through something like template metaprogramming
one of these things is required, no matter what language you use
you might not be aware of it though

it's nonsensical because by itself it assumes you have tagged objects which would be really pointless*

is there a goto meme book for cpp like there is for c
asking for a friend

i use it to print characters as numbers

there is literally nothing wrong with this.

trigraphs already slated to get canned in C++17, nigger.

I'm writing some C++ wrapper stuff so I can use GLM within C, is this how you compile C++ and C objects together?

gcc -Iinc -o obj/main.o -c src/main.c
gcc -Iinc -o obj/foreign.o -c src/foreign.cc
gcc -o test obj/main.o obj/foreign.o -lm -lstdc++

use make

I am using make, I'm just asking if this won't bite me in the ass later when mixing C and C++ objects together.

the only issue might be name mangling.

*this;

I already thought of that.

#ifdef __cplusplus
extern "C" {
#endif

should be fine then.
other then that the object files are pretty much the same.

...

C++ is the powerful programming language in the world.

>hurr durr i'm a retarded brainlet so i'll keep using C

>Falling for the auto pointers meme

Fucking nigger. HolyC is a C++ derivative. Not C.

error: invalid use of 'this' in non-member function
1[this]

????

lol retard

Correct, here is proof (very platform specific, but works right now with cpp.sh)
cpp.sh/4rh4

And here is a simple proof: cpp.sh/4banh

Which one is more visually appealing?

...

You are joking right?

#define delet delete

delet this;

this is a C++ thread

i am not sure it is, actually.

>signed char is treated different to char in C++ templates
>Even though char is signed
>No other type is treated this way
Literally why?

wat

`signed int` and `int` select the same template overloads.
`signed char` and `char` do not, they are apparently distinct types.

I don't know about function/method overloads, I only discovered it when doing something with templates.
No idea why they would do that.

Signedness of char is implementation defined, and can be toggled with a flag in GCC at least.

>char - type for character representation which can be most efficiently processed on the target system (has the same representation and alignment as either signed char or unsigned char, but is always a distinct type).
>the signedness of char depends on the compiler and the target platform: the defaults for ARM and PowerPC are typically unsigned, the defaults for x86 and x64 are typically signed.

Huh, learn something new everyday, I guess.

it would of been nice if they used char for just characters,
and use signed|unsigned byte for everything else.
at least c++ has a std::byte now for that purpose

>std::byte
This is starting to get ridiculous. I love C++ but man, we need a breaking change to just take a moment and fix the ugly shit.

ahh, nvm.
std::byte isnt used for numbers.
just for raw memory and bitwise operations

>at least c++ has a std::byte now
Yeah and it's fucking useless in literally every single situation. Pic related.

>NOT AN ARITHMETIC TYPE
I mean fucking come on, they really had the chance to redeem themselves by adding a byte type distinct from (unsigned) char, but they had to FUCK IT ALL UP as usual.
Fuck the committee.