Just for fun

http://ideone.com/7k891J
1
2
3
4
5
6
7
8
9
#include <vector>
;
int main()
{;
	{;
		;{;std::vector<int>{-1, {}, 1};};
	};
};
;
I showed this to ResidentBiscuit and all he had to say was "what the hell lol".
closed account (Dy7SLyTq)
how did you come up with this?
closed account (N36fSL3A)
1
2
3
	{;
		;{;std::vector<int>{-1, {}, 1};};
	};
How is that even valid? VS2012 complains whenever I do this:

{/*code here*/};
closed account (Dy7SLyTq)
i kind of get it looking closely. the semicolons and the bracket scoping was throwing me off. really it would just be this:

1
2
3
4
5
6
#include <vector>

int main()
{
     std::vector<int>{-1, {}, 1};
}

im still not quite sure what that does though
@DTSCode^2: Dyrand and I were in IRC with ResidentBiscuit and we got on the topic somehow.

@Lumpkin: Try { /*code here*/; } instead.

@DTSCode^1: Yes, that's right - it just makes a temporary vector of ints that contains -1, 0, and 1.
Last edited on
closed account (Dy7SLyTq)
is there another channel beyond #cplusplus? cause i dont think you got on that today. i didnt see it in the logs. also, when would you need to create a temporary vector of ints like that?
We have an IRC channel for ChessPlusPlus, sometimes we get off topic.
DTSCode wrote:
also, when would you need to create a temporary vector of ints like that?
In this case it's pointless, but as an example of when you would want to create a temporary instance of anything is to pass it to a function or constructor.
My brain just fractured trying to work out what the point of that code was. Thank you for explaining a bit, otherwise I might have started drooling and talking to myself.
Last edited on
Wait, is this supposed to look like something, or is it just a random piece of code with a bunch of curly braces and semicolons?

...I guess with a little stretch of the imagination, you can kinda make yourself think that it looks like a sideways image of a rocket leaving a launch pad....

Anyways, this is my favorite random piece of code (I don't even know why):
1
2
3
4
int main()
{
    [](){}();
}

@LDM: Even better:
1
2
3
4
int main()
{
    []{}();
}
Topic archived. No new replies allowed.