|
Today i found some really weird expression in some C++-code
if(++(k=j) != node.end())
{
if("something" == *k)
doSomething();
else if("something other" == *k)
doSomethingOther();
}
and just ~30 lines below that weird if statement i found this:
k = j;
if(++k != node.end())
{
if("something" == *k)
doSomething();
else if("something other" == *k)
doSomethingOther();
}
why always so weird? Why don' to it in an nice way
k = j + 1;
if(k != node.end())
{
if("something" == *k)
doSomething();
else if("something other" == *k)
doSomethingOther();
}
In some other code a few days ago i found this
n[idx++] = a[++idx2]++;
where both, a and n, are defined as void*
What are the ugliest C++ expressions that have you seen in the last few weeks/months
|
|
|
|
|
C3D1 wrote: why always so weird?
Hmmm... isn't that a programming question ?
[EDIT: Silly me! I thought we were in the Lounge ]
I think some people write such nasty stuff because it makes them feel smart. And maybe, a few of them think that it compiles into faster code
Life is too shor
|
|
|
|
|
The shorter the code the faster it gets... thrown out of the window along with the programmer
I sometimes write artworks like that but in 5 minutes I expand them to the readable form. It's just better.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"When you have eliminated the JavaScript, whatever remains must be an empty page." -- Mike Hankey
|
|
|
|
|
My favourite is the --> "operator".
int counter = 10;
while (counter --> 0)
{
}
Some people consider it ugly.
|
|
|
|
|
It's... wonderful. And weird.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"When you have eliminated the JavaScript, whatever remains must be an empty page." -- Mike Hankey
|
|
|
|
|
Brilliant!
I actually Googled to find whether that "operator" really exists in C++!
You have just been Sharapova'd.
|
|
|
|
|
That's evil.
Kitty at my foot and I waAAAant to touch it...
|
|
|
|
|
isn't that a C++ 11 feature?
I'm currently using the VC6 compiler... There is no C++ 11
|
|
|
|
|
C3D1 wrote: k = j + 1;
That is a mistake. k obviously is a pointer and ++k will not increment this pointer by just 1 byte. It will increment it by the size of the type of k. Try it out and examine the memory address k points to in the debugger in both versions.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
CDP1802 wrote: C3D1 wrote: k = j + 1;
That is a mistake. k obviously is a pointer and ++k will not increment this pointer by just 1 byte. It will increment it by the size of the type of k. Try it out and examine the memory address k points to in the debugger in both versions.
I think you're mistaken. k gets assigned j + sizeof(*j) , not j + sizeof(*k) . Hopefully j and k are compatible pointer types.
Edit: I'm not sure what k = j + 1 has to do with ++k . In any case, ++k does not increment by the size of the type of k, but rather by the size of the type k references.
modified 13-Oct-15 13:02pm.
|
|
|
|
|
Vile. Implementation-dependant. 
|
|
|
|
|
C3D1 wrote:
What are the ugliest C++ expressions that have you seen in the last few weeks/months
In no particular order[1]:
#include "stdafx.h"
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_COMMAND(ID_HELP, OnHelp)
END_MESSAGE_MAP()
CMainFrame::CMainFrame()
[1] Oh who am I kidding, it's Friday and I'm just going down a file and pasting in the order found.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Oh my god... The MFC MESSAGE_MAP... How could i miss this rape on #define-macros and the whole C++ Language...
|
|
|
|
|
Thinking it's 21st century I registered with my name (Blažko, note so called soft z in the middle) and published something like an eBook.
Than I found that in some situations I see there my name as Blažko (what I reported them), even directly book's page is OK.
Later, after filling form (where is already no chance to change any name) I got this wonderful reply:
"Unfortunately, we are unable to approve your ad as your book's author name violates one of our ad guideline policies. i.e; the cover page has the name which is not correctly displayed/spelled."
ROTFL (There is no problem with cover page[^].)
(Actually they already "reached out to our technical team to investigate this issue. We'll contact you with more information by the end of the day on October 13, 2015.")
|
|
|
|
|
if you have ever wrote a proxy server and just wanted to relay SSL data then you just need to read the HTTPS connect to get the host name and then join the client socket to a server socket and pump the data between sockets.
Doing MITM after first installing a CA certificate on the client machine so that it works in stealth mode is not so easy and you need to use a SSL-Stream to authenticate with both the client and server to decrypt the data.
Trouble is a SSL-Stream in stealth mode won't give you the host name and if you read the socket that the SSL-Stream is conncted to so you can parse the host name from the stream then the SSL-Stream won't work, it's read forwards only.
So how did i patch this up to work using .NET 3.5 ?
Well i used something like two proxy servers and the first one read the socket stream to extract the host-name and then relayed the data to a second proxy that connected a SSL-Stream to the incoming net.socket and then asked the first proxy for the host name.
browser->host-name-proxy->MITM Proxy->Internet
OK i wrapped it up inside a single class so that it all worked inside a single proxy server on the same process id but i must be very cleaver for thinking outside the box and getting something to work or went about it all wrong and must be very stupi.
Maybe I needed to use some other network base class.
shoot away, it's code Jim but not as we know it
|
|
|
|
|
private void ZombieCheck() {
if (IsZombied) {
if (IsYukonPartialZombie) {
_internalTransaction = null;
}
throw ADP.TransactionZombied(this);
}
}
The code is perfectly good - it's the names that amuse..
Extra points - which large software company does this code come from?
|
|
|
|
|
Duncan Edwards Jones wrote: Extra points - which large software company does this code come from?
Too easy[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Beat me to it
Always remember that you are absolutely unique. Just like everyone else.
|
|
|
|
|
When I read your title I thought of one of my favorite pinball tables
I never finish anyth
|
|
|
|
|
That's the spirit Thing, lend a hand!
|
|
|
|
|
I was more thinking about the Bride of Pinbot, but that works with The Thing, too
I never finish anyth
|
|
|
|
|
Why...?[^]
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Would've been funnier if it was displayed in red
|
|
|
|
|
I thought only end users did stuff like that!
"Go forth into the source" - Neal Morse
|
|
|
|
|
Looks like the work of a tool. Unlikely that developer wrote it.
Mysteries remain, two of which are:
- How come the other entries (like Rock Gardens, Parkdale) don't have it?
- How come the 'obscure Firefox glitch', first reported in 2004 is still under resolution?
|
|
|
|