[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

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

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 81
Thread images: 11

File: c++logo.jpg (4KB, 118x118px) Image search: [Google]
c++logo.jpg
4KB, 118x118px
Daily reminder that this is a valid C++ expression:
 1[this] 


Also, C++ thread.
>>
>>60993185
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.
>>
>>60993274
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.
>>
>>60993274
...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.
>>
>>60993391

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.

>>60993473

Trigraphs are gone in C++17(?) so that should no longer happen.
>>
>>60993391
1 gets converted to ptrdiff_t
>>
File: 1497827764994.png (537KB, 1920x1080px) Image search: [Google]
1497827764994.png
537KB, 1920x1080px
>>60993185
take your POOlang to >>>/trash/, pajeet
>>
>>60993185
c++ is for niggers
>>
>>60996756
this
>>
>>60996810
>>60996756
literally why?
>>
>>60996849
niggers are too dumb to even understand C
>>
>>60996849
https://vc.gg/templeos/Terry%20A%20Davis%20Live%20Stream-xmB_VdDiLPA.mp4
>>
>>60993274
>method
>>
>>60996993

method is just another word for member function. There's no point splitting hairs about terminology.
>>
>>60996936
I don't see any advantage personally from using C over C++

>>60996967
Terry wrote his own C compiler, of course he thinks C++ is for niggers.
>>
>>60997008
>of course terry runs ubuntu is for niggers
>>
>>60997008

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.
>>
File: 1490122282187.jpg (57KB, 819x705px) Image search: [Google]
1490122282187.jpg
57KB, 819x705px
>>60995683
>reading c++ code
>having to think like a compiler
can autism levels reach that high?
>>
>>60997008
>I don't see any advantage personally from using C over C++
kill you're self
>>
>>60997124
ok
>>
>>60997124
will do sir
>>
>>60995683
Maybe it's a macro
>>
>>60993185
delete this;
>>
>>60995683
It's true. C++ is straight up unreadable. It took them one and a half decade to create a fucking half assed refactoring tool
>>
>>60997355
this should have been a reference and not a pointer
prove me wrong
>>
>>60997099
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."
>>
>>60997393
http://www.cpp.sh/5uapd
>>
>>60997393
Why tho. The purpose of references is to avoid pointing to uninitialized/invalid memory.
>>
>>60997479

>explicitly calling delete
You're doing it wrong.

>>60997529

this always points to initialized memory.
>>
>>60997567
it's a "delet this" meme.
>>
>>60997567
>this always points to initialized memory.
Not after you delet it.
>>
File: 1496276147267.gif (2MB, 205x221px) Image search: [Google]
1496276147267.gif
2MB, 205x221px
Post yfw even Java has modules these days
>>
>>60998323
>these days
this is what a bandwagoning retard looks like
>>
>>60998376
S A L T Y
A
L
T
Y
>>
>>60996756
Just like your mama.
>>
>>60993473
>no return 0;
>>
>>60997479
I don't think that works
http://www.cpp.sh/5w2su
>>
>>60998911

Freed memory is not immediately overwritten.
>>
>>60996756
ur mom is for niggers
>>
>>60999059
FOUND THE
N I G G E R
I
G
G
E
R
>>
File: standard.png (66KB, 759x983px) Image search: [Google]
standard.png
66KB, 759x983px
>>60998663
> implying you need to
>>
>>60993274
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
>>
>>60999276
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
>>
>>60997414
i use it to print characters as numbers
>>
>>60997355
there is literally nothing wrong with this.
>>
>>60993473
trigraphs already slated to get canned in C++17, nigger.
>>
File: shimakaze-kun2.png (85KB, 592x576px) Image search: [Google]
shimakaze-kun2.png
85KB, 592x576px
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++
>>
>>61001846
use make
>>
>>61001932
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.
>>
>>61001846
the only issue might be name mangling.
>>
>>60995110
*this;
>>
>>61001967
I already thought of that.

#ifdef __cplusplus
extern "C" {
#endif
>>
>>61001999
should be fine then.
other then that the object files are pretty much the same.
>>
File: image_6605.jpg (110KB, 759x800px) Image search: [Google]
image_6605.jpg
110KB, 759x800px
>>60993185
>>
>>60993185
C++ is the powerful programming language in the world.
>>
>>60997415
>hurr durr i'm a retarded brainlet so i'll keep using C
>>
>>60997567
>Falling for the auto pointers meme
>>
>>60997008
Fucking nigger. HolyC is a C++ derivative. Not C.
>>
>>60993185
error: invalid use of 'this' in non-member function
1[this]

????
>>
>>61003527
lol retard
>>
>>60998911
>>60999028
Correct, here is proof (very platform specific, but works right now with cpp.sh)
http://www.cpp.sh/4rh4
>>
>>61006288
And here is a simple proof: http://www.cpp.sh/4banh
>>
File: 1498046451978.jpg (1MB, 3318x1860px) Image search: [Google]
1498046451978.jpg
1MB, 3318x1860px
Which one is more visually appealing?
>>
File: a88.jpg (321KB, 1280x720px) Image search: [Google]
a88.jpg
321KB, 1280x720px
>>61001713
>>
>>61006413
You are joking right?
>>
#define delet delete

delet this;
>>
>>60998663
this is a C++ thread
>>
>>60993185
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?
>>
>>61010111
wat
>>
>>61010192
`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.
>>
>>61010217

Signedness of char is implementation defined, and can be toggled with a flag in GCC at least.
>>
>>61010111
>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.
>>
>>61010263
>>61010283
Huh, learn something new everyday, I guess.
>>
>>61010311
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
>>
>>61010359
>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.
>>
>>61010359
ahh, nvm.
std::byte isnt used for numbers.
just for raw memory and bitwise operations
>>
File: 1475401164410.png (11KB, 731x56px) Image search: [Google]
1475401164410.png
11KB, 731x56px
>>61010359
>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.
Thread posts: 81
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.