Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

C++ is awesome!

Name: Anonymous 2006-11-06 18:09

(a<b?a:b<c?b:c) = val();

Name: Anonymous 2006-11-06 18:23

another one:

(-42)[p] = 0;

Name: Anonymous 2006-11-06 18:52

>>2

that actually works??

Name: Anonymous 2006-11-06 18:52

What the fuck.

I've been using and studying C++ for almost 10 years now and I've never seen shit like this.

Name: Anonymous 2006-11-06 18:54

>>4
With C++, ANYTHING is possible!

Name: Anonymous 2006-11-06 19:27

o rly?

Show me a container class that can safely store different-type objects safely and without leaks... a heterogenous array, if you want to call it that.

Name: Anonymous 2006-11-07 1:34

>>6
std::vector<std::pair<type_enum, void*> >

am i rite!!!?

Name: Anonymous 2006-11-07 2:20

(-42)[p] = 0;
gets compiles to:
mov dword ptr [eax-0A8h],      0
wtf?

Name: Anonymous 2006-11-07 4:09

>>7

I considered doing that but it just seems sloppy.  It looks like it'd work, but somewhere you'll have to write a winding, thick forest of if or switch/case statements.  And excessive branching can really suck balls on some processors (lol Pentium 4 lol).

Although that's probably about as "neat" as you can get in C++, I guess... :/

Name: Anonymous 2006-11-07 5:03

>>8

eax is p

-0A8h is the hex value for -42 multiplied by 4 (the size of an int)

Name: Anonymous 2006-11-07 11:19

>>9

It does work. That is essentially the idea behind variant types.

Name: Anonymous 2006-11-10 3:04

>>9

I thought P4's crappy branching was one of the reasons the "branch prediction" technology in Intel's new processors kicks so much ass.

Name: Anonymous 2006-11-10 19:16

>>12
Netburst P4's have this "feature" due to the xbox-hueg long pipeline where one branch prediction miss costs you about twenty five cycles. That's on a Prescott, mind, it's like eighteen on Northwoods and Willamettes.

Unsurprisingly then the main speed boost from HyperThreading comes from being able to run the other thread while one suffers from a branch misprediction. Goodbye mainstream code performance.

NetBurst was pretty cool though if you first spent about a week coming up with an optimized routine to do something that you'd like. Kind of like an extremely well hidden DSP mode, only you need to do 128-bit wide integer SIMD stuff and no branching to get at it.

Name: Anonymous 2006-11-11 16:30

#define QUESTION (2b) || !(2b)

Name: Anonymous 2006-11-12 14:19

/(2b)||!b{2}/

Name: Anonymous 2006-11-12 14:41

>>14

Old, lame C joke is old and lame.

Name: Anonymous 2007-07-16 5:44 ID:WZdiXT6+

>>3
yes it works, the compiler sees it as *(p-42)
notice that in pointer arithmetic p - n really means p - ((n)*sizeof(*p))

Name: Anonymous 2007-07-16 5:53 ID:Heaven

>>17
Do you really think he still cares?

Name: Anonymous 2007-07-16 6:25 ID:BgKz3ekV

>>4,6-7
This is why C++ is a bad language.

>>9,12-13
You don't worry about that. OMG CFLAGS SUPER OPTIMIZED VEGETA WHAT DOES CPUID SAY ABOUT THE CPU CYCLES OMG ITS OVER NINE THOUSAND!

Name: Anonymous 2007-07-16 6:37 ID:eXsXQjZ9

>>19
You don't worry about that.

Name: Anonymous 2007-07-16 6:48 ID:Heaven

>>19
sounds to me like someone with a slow OS

Name: Anonymous 2007-07-16 17:37 ID:4NnK74Kh

obfuscation is ohsome

Name: Anonymous 2007-07-16 18:51 ID:J2sFyyfu

>>1
That isn't actually too hard to understand

Name: Anonymous 2007-07-16 19:00 ID:1Qg4jL4B

char *foo = (char[52]){0,};

of course, this also works in C99 where it is more cool.

Name: Anonymous 2007-07-16 19:01 ID:1Qg4jL4B

>>24
it's also a cool alternative to

char *foo = new char[52];

when you can't be arsed deleting/freeing it after you've used it. (happens at the end of the scope)

Name: Anonymous 2007-07-17 2:39 ID:Heaven

>>24
it actually works ONLY in c99

Name: Anonymous 2007-07-17 15:53 ID:3FwML6th

>>24-26
No.

char *foo = malloc(sizeof(char) * 52);

Stupid C++ programmers.

Name: Anonymous 2007-07-17 16:05 ID:6hM4VBlk

>>26
no, it works in C++ and c99, you know, 'cause we happened to be DISCUSSING C++.

>>27
char *foo = (char[52]){0,};

works in C99 kthx

Name: Anonymous 2007-07-17 16:24 ID:gcQ4l5vZ

Also:

if(a-2)

instead of

if(a!=2)

Name: Anonymous 2007-07-17 16:56 ID:OqFClqyH

>>29
What the fuck. Gento went that way ------> (out of /prog), now GTFO.

Name: Anonymous 2007-07-17 17:28 ID:uU2y6e+u

>>29
The first statement would get compiled to something like:
mov eax, [a]
sub eax, 2
test eax, eax
jne cond_false

The second gets compiled to:
cmp [a], 2
jne cond_false

Tell me, which one do you think is more efficient?

Name: Anonymous 2007-07-17 17:29 ID:uU2y6e+u

Additionally, the first of the statements lends itselfs to branch mispredictions, potentially making it slower for the CPU to pipeline the correct instructions.

Name: Anonymous 2007-07-17 18:00 ID:kKJBBW+y

if(a^=2) a^=1;

or

a^=a==2?a:3;

?

Name: Anonymous 2007-07-17 18:18 ID:Heaven

>>33
(a^=2)&&(a^=1);

Name: Anonymous 2007-07-18 3:08 ID:3a/FupcC

>>28
[ ]ANSI C
[ ]GTFO

THE CHOICE IS YOURS, SIR.

Name: Anonymous 2007-07-18 3:21 ID:Heaven

ISO > ANSI

Name: Anonymous 2007-07-18 4:34 ID:Heaven

>>27
You're doing it wrong
char *foo = malloc(sizeof(*foo) * n);
Also, YOU DON'T NEED TO MULTIPLY IT WITH sizeof(char), because that is guaranteed to be 1.
A char represents a byte.

Name: Anonymous 2007-07-18 4:42 ID:yz7Aoeaz

>>3
According to the Standard, a[b] is the same as b[a] which both are just syntactic sugar for *(a + b)
So: a[10] is *(a + 10) and 10[a] is *(10 + a) which are both the same thing.

Name: Anonymous 2007-07-18 4:45 ID:Heaven

>>37
If I remember the standard correctly, a character is AT LEAST a byte, but is in fact up to the implementation what the actual size is (depending on architecture and whatnot). Of course, it's been a while since I've looked at the standard, so I may be wrong.

Name: Anonymous 2007-07-18 4:56 ID:Heaven

>>25
Alternative, sure, but not the same. The (char[52]){0,} trick, i believe, would be placed on the stack, the new char[52] on the heap. Minor difference.

Name: Anonymous 2007-07-18 4:59 ID:7uXIxOPr

>>35
Amerifag

Name: Anonymous 2007-07-18 5:51 ID:Heaven

>>39
no a char is a byte.
A char might be a 7bit byte, an 8bit byte even a 36bit byte, but it still would be a byte.

Name: Anonymous 2007-07-18 5:57 ID:mxcr/PD6

>>39,42
No. A char is at least 8 bits. A byte can be any number of bits.

Name: Anonymous 2007-07-18 6:26 ID:LsPuaK1X

You don't get any machines nowadays with a non-8-bit byte.

Name: Anonymous 2007-07-18 6:27 ID:Heaven

>>43
incorrect, if you want an 8bit object you have to use something like uint8_t etc.

a char is a byte.

Name: Anonymous 2007-07-18 6:35 ID:Heaven

>>42,43
Ah, I stand corrected. I think what the standard actually says, then, is that a char is at least 8 bits. Thanks for the clarification ;-)

Name: Anonymous 2007-07-18 6:48 ID:7uXIxOPr

But the standard is a piece of shit. Anything with a name resembling a character should be at fucking least 21 bits, and the ONLY character set which it should ever support should be ISO/10646 UCS. Then strings should be abstracted so you don't poke your nose (overriding [] as necessary) and they should use an implementation-defined Unicode Transformation Format out of the three possible UTF-8, UTF-16 and UTF-32, with full Unicode semantics as defined in Unicode 5.0 and no character set/encoding conversions AT FUCKING ALL. Then, when you want to read/write strings from/to a file/terminale/etc., you either use the Unicode Transformation Format used by the stream (one of UTF-8, UTF-16, or UTF-32, specified when creating it), or you can call the function __WARNING__SHIT_COMING_convert_character_set_yes_I_really_want_to_do_this_yes_I_know_I_shouldnt(str, other_legacy_goddamned_piece_of_shit_charset, FOR_REAL | YES_I_AM_A_MORON_FOR_NOT_USING_UNICODE). Of course, for binary files and sockets, you should use byte arrays, whose type should be byte or signed byte, and you'd have a function similar to the one I described for byte array to string conversion.

That's how things should be done. Anything that's not Unicode should be filtered through kill_this_shit(WITH_FIRE).

Name: Anonymous 2007-07-18 6:53 ID:IGKqSAxO

>>47

ENTERPRISE

Name: Anonymous 2007-07-18 7:00 ID:x4oldEir

Gotta love variable width character encodings

Name: Anonymous 2007-07-18 7:47 ID:Heaven

>>49
I like GSM 7bit encoding.

Name: Anonymous 2007-07-18 8:36 ID:+KT41DJE

>>39
Yes, a byte can be any number of bits.

Name: Anonymous 2007-07-18 8:41 ID:+KT41DJE

>>40
Yes, that was my point. Sigh...

BIG difference, one has to be deleted (new) the other is deleted when the block ends. I.e.


{
    char *foo = (char[52]){0,};
} /* allocated memory is deallocated. */

{
  char *foo = new char[52];
} /* allocated memory still exists. */


HENCE:

"when you can't be arsed deleting/freeing it after you've used it. (happens at the end of the scope)"

Name: Anonymous 2007-07-18 8:46 ID:+KT41DJE

>>47
tl;dr

Name: Anonymous 2007-07-18 8:49 ID:+KT41DJE

>>42
>>43
>>45
ITT noobs confuse C's definition of a byte (implementation specific) with an octet.

Btw an object of type char can hold one (implementation specific) byte.

Glad that's cleared up.

Name: Anonymous 2007-07-18 8:50 ID:i2QKQL/m

>>54
which means that a char is an implementation specific byte.
right?

Name: Anonymous 2007-07-18 9:13 ID:Heaven

>>45
An object declared as type char is large enough to store any member of the basic
execution character set.

a char must be at least 7 bits in c99, since you need at least 7 bits to represent all the characters that must be included in the basic execution character set.

regarding the size of a byte, wikipedia says:
historically, bytes have ranged from five to twelve bits. [citation needed]

Name: Anonymous 2007-07-18 9:51 ID:+KT41DJE

>>55
ja

Name: Anonymous 2007-07-18 10:04 ID:i2QKQL/m

>>57
well i'm >>45 so why are you calling me a n00b?
it's what i said.

a char is a byte
if you want an 8bit object use uint8_t

Name: Anonymous 2007-07-18 10:06 ID:oCpLpYvo

>>56
a char could be less than 7 bits if it was compressed.

Name: Anonymous 2007-07-18 10:06 ID:x4oldEir

I like using uint8_ts instead of chars

Name: Anonymous 2007-07-18 10:16 ID:Heaven

>>59
you can't represent all of the 100 characters that are required to be in the basic execution character set in less than 7 bits.

Name: Anonymous 2007-07-18 10:17 ID:oCpLpYvo

>>59 impossible GTFO.
However if you were using qubits then you could store a char in less than 7 bits.

>>69, 61 same person.

Name: Anonymous 2007-07-18 10:18 ID:Heaven

>>58
A byte can be any length.
A char must be at least 7 bits.

Name: Anonymous 2007-07-18 10:31 ID:i2QKQL/m

>>63
so >>57 is wrong?

Name: Anonymous 2007-07-18 15:42 ID:88NG7eVN

>>39
Nope. Section A7.4.8 (page 204) of the C Programming Language defines sizeof(char) to be 1.

Name: C FAG 2007-07-18 17:11 ID:ROniVmzU

>>1
Oh wow lol. *(a < b ? a : b < c ? b : c) = val(); works for me. Srsly, C++ has seriously gone overboard on the syntactic sugar. It's making code much more difficult to understand.

Name: C FAG 2007-07-18 17:13 ID:ROniVmzU

... of course that compares pointers. what the C++ version with the references does is actually *(*a < *b ? a : *b < *c ? b : c) = val(); which is parsed quite easily given a syntax-highlighting editor.

Name: Anonymous 2007-07-18 18:25 ID:+KT41DJE

An object declared as type char is large enough to store any member of the basic execution character set. If a member of the basic execution character set is stored in a char object, its value is guaranteed to be positive. If any other character is stored in a char object, the resulting value is implementation-defined but shall be within the range of values that can be represented in that type.

Name: Anonymous 2007-07-18 18:25 ID:+KT41DJE

>>68
Section: Language->Concepts->Types

Name: Anonymous 2007-07-19 3:16 ID:7uu/q3iV

ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO. ASCII IS ALL YOU NEED OTHERWISE YOU ARE A WEEABOO.

Name: Anonymous 2007-07-19 5:21 ID:vkspcyb4

>>70
Amerifag thinks no other languages/currencies/symbols/etc. exist. Not a big problem though, Amerifag will soon die of heart attack due to eating at Amerifag "restaurants".

Name: Anonymous 2007-07-19 11:56 ID:JreCCMS8

>>31
CFLAGS motherfucker, do you use them!?

Name: Anonymous 2007-07-19 12:06 ID:Heaven

>>71
Morbidly obese Eurofag just wants to draw attention away from his own obesity.

Name: Anonymous 2007-07-19 14:08 ID:6coq2HlI

>>73
lol I'm thin, kthx

Name: Anonymous 2007-07-19 17:21 ID:Heaven

>>73
Europe is so expensive, we can't afford food. Blame Socialism.

Name: Anonymous 2007-07-20 4:37 ID:7wGDr5GE

>>73
Lol? Amerifags are the ones who are (in)famous for their obesity from eating American-sized shit at American shit dumps they call "restaurants". Everything has to be big and ugly: cars, food, people...

Name: Anonymous 2007-07-20 6:04 ID:Heaven

>>76
PROTIP: most americans don't actually eat that shit.

Name: Anonymous 2007-07-20 8:06 ID:Heaven

>>77
You must be new here.

Name: Anonymous 2007-07-20 17:30 ID:Heaven

>>77
most americans eat shit.

Name: Anonymous 2009-01-14 14:50

ENTERPRISE QUALITY

Name: Anonymous 2009-03-06 8:39

Shit Some of my   contract you can   read more abotu   this practice at   transforming equations Like   doing algebra except   with functions So   it must be   said by him   and as you   can see he   gave up on   the spot nonsense   no one know   a way to   his toy languages   and their advocates.

Name: Anonymous 2011-02-03 5:55

Name: Sgt.Kabu㈻譭kiman蛢ᒗ 2012-05-28 20:48

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List