« first day (805 days earlier)      last day (4157 days later) » 

4:01 AM
gah fuck Sieve of Atkins, I'll stick with my Eratosthenes :(
 
I don't understand the code.
 
// crash N < 4 ?
primes[0] = 2;
primes[1] = 3;
primes[2] = 5;
:)
 
I didn't optimise it yet, I wanted to get the basic one to work but I can't.
N is 2,000,000 anyway so that isn't it.. hm.
 
user142019
Maybe N overflows!
 
4:04 AM
how?
 
user142019
I don't know how big a size_t is.
 
N = 100 results in 17
 
@Zoidberg'-- size_t is 32-bit in most machines
 
Perhaps this case is easier to debug.
 
lol compiler error
 
4:07 AM
Fixed :)
 
Hm.
 
user142019
I'm so thirsty but the nearest coke bottle is downstairs. :L
 
Then die!
 
user142019
A guy who worked for Google complained he had to walk more than 30 meters to the nearest restaurant.
 
Well, 30 meters. If it was any closer then he'd complain about the noise.
 
user142019
4:10 AM
Appeared the nearest restaurant was above him, so within a range of 30 meters. :^)
 
user142019
Maybe not exactly thirty, but something like that. From any room in Googleplex you're at most an X amount of meters away from a restaurant.
 
user142019
That X is something like 30 or 40 I believe.
 
If you want another interesting prime problem, try 381.
 
user142019
> The U.S. state of Nevada passed a law on June 29th, 2011 permitting the operation of driverless cars in Nevada and California.
 
That's the last problem I did to get to level 15.
 
user142019
4:16 AM
WHAT'S THE POINT
 
Of driverless cars?
Those are Google operated.
 
user142019
Yes.
 
I think they want to use them for Google Maps
The Google driverless car is a project by Google that involves developing technology for driverless cars. The project is currently being led by Google engineer Sebastian Thrun, director of the Stanford Artificial Intelligence Laboratory and co-inventor of Google Street View. Thrun's team at Stanford created the robotic vehicle Stanley which won the 2005 DARPA Grand Challenge and its prize from the United States Department of Defense. The team developing the system consisted of 15 engineers working for Google, including Chris Urmson, Mike Montemerlo, and Anthony Levandowski who had worked...
 
std::exception::what returns a const char* detailing what happened exactly for that exception
 
@Rapptz You got that far?
 
4:23 AM
It's virtual, which means it's overridable in derived exception classes.
 
@StackedCrooked I have exactly 375 solved.
 
Awesome.
 
user142019
@ThePhD is that a reply to something? It seems such a random message. xD
 
I wonder where the char* for that is stored...
Um. Typing to myself, I think, because Notepad got boring.
 
I got stuck on this one. However, it's 5:30 AM, which might affect my problem solving skills :)
 
4:25 AM
Trying to figure out what to make of what()
 
user142019
@ThePhD implementation-defined.
 
@ThePhD Make a castle of it.
 
user142019
If they are always the same then they are just implemented with string literals.
 
Maybe I could just override it altogether and not give a bollocks about what std::exception stores in the first place.
Could be a waste of space, though I could always just pass down null and save myself the heartache.
 
user142019
what() is extremely useless and you should only use it for debugging.
 
user142019
4:26 AM
And even then, a stack trace is often more helpful.
 
user142019
For different kinds of errors use different exception classes.
 
I think I'll have to learn how to use __StackWalk and __StackWalk64 if I want to generate call stacks, that's for later.
Haha, shit.
 
"Can I afford stack unwinding here?"
Fuck no.
 
4:29 AM
^ This is quite nice.
 
Back to writing the bool version.
 
user142019
> It's nice to have a message that a programmer stands a chance of figuring out, but you're very unlikely to be able to compose a relevant and user-comprehensible error message at the point an exception is thrown. Certainly, internationalization is beyond the scope of the exception class author.
 
Maybe this is why Error Codes are used.
 
user142019
Don't use error codes.
 
Well it's either bool, int32, or void + exceptions.
 
4:31 AM
@StackedCrooked Hm. I recall I did that one by mathematica searching
 
user142019
Instead, make AccessDeniedException, FileNotFoundException, FileIsADirectoryException, etc... as different classes.
 
My thought currently is that I can predicate an Exception version of the code based on an Error-Code version of the code.
And the bool version can likewise be predicated off of an error-code based API.
Then it's just making different function signatures, to be usable in any case where the user feels like it.
In this case, the user is me, and I never liked Exceptions, even in C#.
 
> Often the best way to deal with exceptions is to not handle them at all. If you can let them pass through your code and allow destructors to handle cleanup, your code will be cleaner.
Yeah!
 
So RAII + no try catch.
Sounds like the RAIIght thing to do!
4
 
High five!
:D
 
4:35 AM
Jumps up for a MEGA-HIGH-FIVE.
 
lol
you need a break
 
You're right, I've been at this for hours. ._.
But on the bright side, the system I thought up for Resource Cache is very robust and completely RAII'd.
It also uses TypeErasure to cheat a whole lot.
 
get a hold of yourself man
 
I can't, man.
All the file formats.
Alllll the files formats. +_+
 
make a new file format
.phd
 
4:41 AM
I'm thinking about that actually, for 3D Models
I really don't want to parse this .fbx mess. ~_~
 
already taken
 
PC Help Desk File?
Fucking really?
 
PolyHedra Database is what I'm getting
 
As cool an extension as PhD is and someone uses it as a fucking Helpdesk file.
Fuck my life.
 
4:45 AM
Pretty cool, but not as cool as Hooker Traits
 
@StackedCrooked using <false> specialization aids readability
 
Hm.
I'm gonna have to delete a void*
Somewhere, somehow, I've failed. =[
 
@Pubby I guess. But I think the design with the second template parameter as optional is kinda wrong.
 
template<unsigned N>
struct number : select<N, N % 2>
instead?
someone upvoted all my old posts
 
more like number : select<N % 2 == 0, yes_type, no_type>
I think.
 
4:51 AM
@StackedCrooked I don't understand
you mean like std::integral_constant<bool, N % 2 == 0>?
 
@Pubby I mean that an interace like select<N, N %2> allows the user to cheat and type select<N, true>.
So I would encapsulate that. (Not a super example. But you probably get my point.)
Ah, well, I'm just messing around.
It can probably be done with enable_if also.
 
anyone here have any insight on asm?
 
5:27 AM
@ThePhD I've worked out a little more. (Not sure if useful though.)
 
:O
That's actually pretty amazing.
I can think of a few uses for it but that's still amazing.
 
Hooking in general is a useful thing. Not sure how my class will fit in real-life scenarios.
I guess I'll have to try using it :D
 
5:45 AM
guys, codepad.org/W2aSIcCi guys, this is shameful but I am not getting this program.
the second time when the function prtfun is called, what will be values of a and b, wil it be 4 and 6 or 2 and 1
 
void main() ?
 
??? @StackedCrooked
 
Not valid, and doesn't compile on GCC.
 
it does on codepad, that matters
:)
 
5:59 AM
dunno @StackedCrooked
 
@StackedCrooked I like that Hot'n'Cold song, by the way.
 
a+=++b; might be UB.
@ThePhD Awesome.
 
@StackedCrooked It's not.
 
c = a+++++++++++++++++b;
 
6:03 AM
@StackedCrooked, thank you, but can you tell me what would be the value of a and b after the first time the function prtfun is called
 
@AnujKaithwas Use a debugger, stepthrough, and win candy.
 
@LucDanton Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression. So, because a and b are only modified once in the expression there is no problem. (Am I getting it right?)
 
Why would a += ++b be UB
 
whats ub?
 
That's exactly my question.
 
6:08 AM
It's pretty straightforward to reason about
 
@StackedCrooked Not enough SAN points left to handle more standardese, sorry.
 
@LucDanton You still have those?
That probably means you should chat more
 
I'm keeping them in a box under my bed.
With a padlock on the box. Obviously I'm safe now.
 
^ Kindred, by Burial
 
cpx
@CatPlusPlus Because b is evaluated only once, right?
 
6:13 AM
IIRC because both a and b are only modified once.
 
Because there's no "variable is modified twice in an expression where order of evaluation is not specified" situation
I don't know why would you even think about UB being here or not
It's pretty obvious
 
cpx
I just read about += operator yesterday :P
 
New procexp displays GPU usage per process
Neat
 
@StackedCrooked You define template<typename T, typename U> void foo(); twice.
 
That makes sense.
 
I was trying to apply the info found here.
 
The reason that the trick with default arguments is mentioned is that it works back even with GCC 4.6 (I think?), whereas using EnableIf 'clauses' requires something p-to-date, if not bleeding edge.
 
 
1 hour later…
8:25 AM
hi all
hi everyone
 
@user1726647 Well, hello.
 
i m a newbie here....
i want ask something about linux server programming ....may i ??
 
YES
This is the right place for all sorts of questions
 
There's nothing wrong with asking.
 
sir ,
 
8:28 AM
In fact, you have come to the right place.
 
when we make a socket descriptor ..
 
@KonradRudolph Guess what, CUDA scheduled for death in 4 to 5 years. Also OpenCL is probably gonna get killed in the process. Fuck.
 
is there a difference between the "port no. " of processes and the one we use in socket programming
are both of them .. the same thing ...
?
 
The port used by your application is the same as the one used by the system if that's what's you're asking
 
ya...
 
8:30 AM
Well then yes.
 
so , when a socket is bind() to a port , then if a lot of clients are there , then that port or process wont get hang ...why ???
 
? please reword
 
i mean sir..... how can only one port handle a lot of requests from a lot of clients ...????
 
Ah I think I see your confusion
When you bind() your socket and then listen() for clients, you open a listening socket
 
plz help me sir...
 
8:34 AM
When you call accept() on that socket, it opens a new socket for your client
 
sir ..u mean ...for every new client there is a "new socket " ??
 
cpx
@user1726647 You're speaking with Ma'am. >.>
 
sorry
 
Hahaha
 
8:36 AM
@user1726647 Yes, transparently accept() opens for you a new socket on a new port, used for communication with the client that just connected.
 
Now don't start calling Ma'am. :p And you don't need to put dot dot dot
 
okay, cant we use a new thread instead ??
 
That's unrelated
With TCP you will always get a new port.
No matter whether you use the same thread or not
Also, the 1-thread-per-client approach doesn't scale well
 
ohhhh
u mean , its better to use "a new port or process" instead of "a new thread"....?
thanks mam
 
It depends on your needs
If you don't need scalability one thread per client is fine
 
8:43 AM
okay mam
 
8:57 AM
Hahaha!!! Silly me.
 
9:27 AM
@Xeo I guess Muv-Luv is mandatory before starting Muv-Luv Alternative?
 
9:39 AM
hi to alll.........
 
cpx
Hi
 
10:04 AM
hi
 
I'm going somewhere fiery and scary for this, but I randomly managed to get concept-like stuff working for functions (but with no pretty error messages). template<typename T> CONCEPT_FUNCTION foo() RETURNS(int, REQUIRES(std::is_default_constructible<T>) and REQUIRES(std::is_move_constructible<T>)) {return 5;}
I don't plan on spreading/using it, don't worry.
The only problem I can see is that it doesn't work with void as a return type.
I have something that overloads && to give back the other type so that no matter how many requirements it has, the first argument is what the resulting return type ends up as, but of course you can't do && with void.
 
is there a IDE for C programmming like eclipse or xcode in which , it shows suggestions and show compiler warnings while coding itself ???????
 
10:29 AM
-3
Q: Why is -i++ and -(i++) different ? Why is the result as follows?

GrinV Possible Duplicate: Order of evaluation of arguments using std::cout I have known it now!This is responsible for 'cout' The all code: #include <iostream> using namespace std; int main() { int i = 3; cout <<-i++<<endl<<i<<endl<<-(i++)<<en...

> I have known it now!This is responsible for 'cout' The all code:
lol
 
hej killar
 
cpx
Is int i = 0; +i++; undefined behavior? AFAIK + does nothing.
 
You're not modifying it twice. -i++ is not either.
 
I don't see much point in writing stuff like that except for code golf
 
I'm surprised no one has flamed me over the concepts thing yet.
 
10:44 AM
@BenVoigt incorrect. If N * 2 and N + N will result in a different value for some N, then both of the definitions define different function templates (and the ODR won't apply). If not, for all N (as they do here), then both of the definitions define the same function template (they are said to be functionally equivalent). But if the token sequences are different (and here, they are), then they are not equivalent. The spec says if two function template declarations are functionally equivalent but not equivalent, then the program is ill-formed, and no diagnostic is required. — Johannes Schaub - litb 6 mins ago
:)
 
11:11 AM
morning noobs
 
it's morning only in your lame timezone,
 
STOP. it's morning whenever I wake up!
 
indeed
 
yeah, but since I'm awake, it's not a morning.
 
11:25 AM
I just got up, too. Overruled, It's morning :p
 
Noon in Sweden but feels like in the middle of the night
 
11:37 AM
Sweden's cold
:P
 
Yeah, but it has been a super winter thus far, lots of snow and -4°C for like a month. I like winter when it is like that. Last year we had almost no snow, that was no fun.
 
Here in UK midlands, it's rain, rain, rain. Fields flooded, some roads impassable. Last week, the dray truck could not get through with the beer:(( No prospect of snow. Spent Christmas refuelling pumps outside :( OTOH, my code is working well enough to deliver soon.
 
12:02 PM
I would not want to trade^
 
Every time I sit at my desk after getting soaking wet, again, I look longingly at my passport. If I had not work to do, I would be gone by now. I cannot work from a hotel room in the Canaries, or whatever - I have special hardware:((
 
@StackedCrooked What a pile of contraptions
 
Old geezer likes to show his grand kids a few tricks from the olden days :)
 
@FredOverflow the engrish... ouch
@StackedCrooked ye olden alright. I'm positively flustered how he didn't just make_unique or even boost::optional the storage. And it looks to me he didn't even use his badly named check_reference trait
 
The subtitle of this blog is awkward.
C++ does that to certain people.
 
To be honest, I think boost::optional and boost::flyweight may come with more functionality out of the box.
Perhaps he should have a look at a general purpose, generic memoization in ~15 lines of code in C++11
 
12:41 PM
hmmmm
 
1:02 PM
meh.. optional could be built-in, like T?
 
no
 
why not?
 
because there's no advantage to making it a language feature instead of a library feature
 
@DeadMG say it to boost.lambda
 
please, do learn what you are talking about
there's a bunch of features of language lambdas that could not, ever, be implemented as a library.
there are no features of optional that cannot be implemented as a library, or would be implemented much easier as language.
 
1:05 PM
the most important feature is "short syntax"
 
the difference between T? and std::optional<T> is irrelevant.
 
anyway, it just won't happen =\
 
and for good reason
although std::optional<T> may well happen
 
also it will be std.optional<T>
meh... we have so many characters - `@#$? why don't just use them...
 
because using them is bad.
they're completely opaque and they add substantial language complexity
a library feature is far cheaper to both implement and use reliably and safely
and it's much easier to Google std::optional> thatn T?
 
1:12 PM
"complexity?" yeah, it's when you spent weeks to write a library to work around "language simplicity"
 
writing std::optional is far easier than changing the compiler to support T?.
 
@DeadMG you can't even write optional<> without a typo
compare it to "?"
 
@Abyx Sure I can. std::optional<T>.
I was just writing that whilst Starcraft 2 was loading and it gives some nasty lags for the whole of Windows when that happens.
 
@Abyx even in C# T? is just a shorthand for System.Nullable<T>
@Abyx ad hominem meets anecdotal evidence :)
 
1:21 PM
"Section::PointerToRawData is insane!"
thank you so much for your helpful insight, LLVM
 
i recommend &&& as optional indicator
int &&& a ; if(&&&a) { std::cout << a; } else { /* empty */ }
lol
 
@JohannesSchaub-litb looks very convenient
 
(it was a joke, dear!)
 
also
&&&a = 5;
and std::cout << &&&a;
 
"&&&a" returns a bool indicating whether the optional variable stores something or not
i mean, since we have discovered the great uses of & in C++11, we could just add another use xd
 
1:27 PM
@JohannesSchaub-litb yeah, it's would be a good tradition to add more & in each standard
 
this just in, &&&&a- std::vector<a>
int&&&& a; &&&&a.push_back(5);
 
a void is always considered empty
 
cpx
lol
 
so a vector "v" when v.push_back(x) yields a prvalue void will yield true with &&&v.push_back(x)
it could be an lvalue..... &&&a = false; /* make a empty without changing the value bit pattern */ &&&a = true; /* now a has the value again */
 
goddamnit
LLVM why can u no output a proper .o file :(
 
1:40 PM
What are you working on?
Not Wide, was it?
 
yes, actually
but I can't persuade LLVM to emit valid object files
 
Ell
Hi guise
 
1:56 PM
fucking hell
 
I remember at my first job I had to use the in-house GUI library. It was a horrifying experience. I wanted to construct a fairly window with some layouting and event handling. Every little thing I tried didn't work. So the routine became that I tried something, gave up in frustration and and asked a more experienced colleague to look at my code and help fix it. Over a period of nearly a year my experience changed from "How can I get it ever right!" to "How could one possibly get it wrong."
 
use LLVM's function to write bitcode... use LLVM's object file utility to load it ... it says bitcode is incorrect.
 
I normally start with Googling the error message and hope that I get an instant solution. If all fails then I take my notebook and start to write down the steps that lead to the problem. I usually also write the full error message by hand.
Writing by hand is slow. I find that helps me understand the problem...
Ah well.
 
yay fixed
turns out that I didn't open my file stream in binary mode /whoops
 
You fixed the bug in LLVM? :P
 
2:03 PM
probably also explains why the object file was incorrect
 
^ I loved this in 2007.
Time flies.
 
hmmm
now I've got a bunch of undefined reference
 
To think that Stallman wrote gcc, gdb and emacs himself.
That seems beyond human.
 
I thought that Stallman never had any code committed to the GCC project.
also, that's only beyond human in their current state- the GCC of 1970 would have been vastly simpler and smaller than it is today.
 
Ell
I think writing and finishing anything on your own requires a lot of commitment
 
2:09 PM
I guess.
But then again tools at his disposal were austere relative to current tools.
Ah well.
 
yeah, but the complexity has increased far faster than our tools have
 
Yeah. In the past there was the distinction between analyst and programmer. The programmer was assigned the modules that he needed to implement in the system.
Today it's like we need web shop by tomorrow.
 
@Ell Extended periods of manic phase might help, just gotta take care not to wipe the entire repo when it swings
 
btw
how does linker order matter for static libraries?
 
Ell
2:29 PM
@JohanLarsson Ooh must check out your bitmap testing today
 
I don't know how, but it has happened a few times that it mattered. IIRC believe boost system library likes to be included after the source files.
 
Ell
@DeadMG it does IIRC :P
 
@Ell Is this still valid? I think it is the latest. I'm a bit suspicious about the tests, dunno if the compiler found a way to optimize. Did not check the IL
 
Ell
@JohanLarsson the paste is still valid but I haven't tried - I'm rather busy today
ahh bacon is ready :P
 
2:31 PM
higher lvl first, lower lvl last (start with undefined symbols that get defined as you go from left to right, or high to low) for gcc/ld - I dunno about llvm
 
Should this be [C++-faq]?
 
@Ell Added try-finally for the locking. that is probably a good idea
 
7
Q: What is meant by Resource Acquisition is Initialization (RAiI)?

JohnWhat is meant by Resource Acquisition is Initialization (RAiI)? www.technical-interview.com

 
@CatPlusPlus Apparently that was wring and didn't work on Firfox. This seems to work nicely. (Change location.hostname instead of location.host and this code outside of window.onload.)
 
2:57 PM
@rubenvb Alf once explain that RAII's meaning is twofold: the scope-bound resource management part, but it also means that object should be fully initialized after construction. The latter fits the acronym much better IMO.
 
3:25 PM
ARGH
Clang Y UR FUCKING WORTHLESS OWNERSHIP FAILURES
 
user142019
3:37 PM
@JohannesSchaub-litb T? a
 
hmm
maybe I should just give up on linking to the Standard library
 
user142019
When Google Glass gets released I'll lay down on the ground, make weird rotations and froth.
 
user142019
Also.
 
user142019
Time for diner breakfast.
 
@Zoidberg'-- Something sexual?
 
user142019
3:43 PM
Something rabies-like.
 
user142019
visual /b/asic
 
Nice :)
 
hmmm
turns out that just g++ main.cpp is enough to link a cpp file to the mingw standard lib
but g++ foo.o won't link foo to the mingw standard lib.
le curious?
 
Guuiiiisssssssss
 
must be a configuration error in Clang, surely.
 
3:56 PM
@DeadMG Sounds like it, but I've never done these kinds of things. :D
Quick question. for template parameter deduction, I have a function signature like: template <typename T> void WarbleGarble ( T*& value ) { /* ... */ }
 
yes
 
@DeadMG g++ foo.o -o bla.exe should link the standard libraries.
 
user142019
Man.
 
user142019
I woke up at four.
 
user142019
What an utter waste of time.
 

« first day (805 days earlier)      last day (4157 days later) »