« first day (467 days earlier)      last day (4467 days later) » 

Xeo
11:00 PM
Maybe you also like stomache aches?
 
no
 
0
A: How to deallocate variables on the stack?

FredOverflowThe only thing you can do is to destruct a variable on the stack (that is, invoke its destructor), but you must make sure that you construct it again before it goes out of scope, or you enter undefined behavior land. Since your motives aren't entirely clear to me, maybe that's what you're asking ...

 
0
Q: How to store a memory address in C++?

FarhadI have a memory address that I want to store. I DO NOT want to create a pointer to that address, I simply want to store it in a variable. I do not know and do not care about the type of information at that memory address. What would be the ideal variable to store it? I am using C++.

More from the same source.
 
> I have a memory address that I want to store. I DO NOT want to create a pointer to that address
LOLWOT
 
Just look at the answer he commented on!
Storing it in a string is "exactly what [he] was looking for".
 
11:05 PM
@DeadMG I think he comes under the "troll" heading
 
Xeo
I have the sudden urge to downvote all that guy's questions and answers
 
@FredOverflow I'd be a lot happier with that answer if the std::string was originally created in a buffer to avoid UB (if the constructor fails for any reason). Then suggest boost::optional.
 
let the downvotes commence!
 
"Why was this question downvoted?" Because it's fucking stupid, that's why.
 
@FredOverflow I think you should link to the question we asked the other day about how this is a nasty practice (anyone has a link around?)
@Xeo I downvoted two of them. Guess which.
 
Xeo
11:06 PM
Same
14
A: How to store a memory address in C++?

Carl NorumA pointer is a variable that stores a memory address. End of story. If you don't care about the type, you can use void * to indicate that you're not interested in type information.

That guy might be in for a reversal badge
+16, -3
 
> Thanks, thats perfect. – Farhad 3 mins ago
He accepted Fred's answer.
 
Can we stop talking about this?
And forget it ever happened?
Because aaaaargh.
 
Xeo
14
Q: Can I get a fresh start in C++ without failing again?

Kerrek SBSometimes it's nice to start over. In C++ I can employ this following simple manoeuvre: { T x(31, Blue, false); x.~T(); // enough with the old x ::new (&x) T(22, Brown, true); // in with the new! // ... } At the end of the scope, the destructor wi...

@RMartinhoFernandes ^this
 
@Xeo Thanks but I already linked to it :P
 
11:09 PM
> It's well known idiom. 31 and 22 are ages, Blue and Brown - color of the eyes, false and true - either love, but most likely breasts. Bottom line, somewhere along the lines (of your code) your new girlfriend will become x too. – AzzA Jan 12 at 3:01
 
Xeo
The comments on that question are insane
 
> @KarlKnechtel: Oh, T doesn't have an ass. operator. Let me edit. – Kerrek SB Jan 12 at 3:07
Lol.
 
Xeo
Ooh, I just thought of another nice answer to the stack deallocation question
 
Ass operator.
 
Xeo
exit(0) - ends the life of the application and as such deallocates the stack :>
and with it, any variables living in there
 
11:11 PM
Hurray, linking is done and actually produced an executable!
 
@Xeo not quite, because the variable goes out of scope. He specifically stated before it goes out of scope
 
I sense two reversal badges coming.
That guy is ike a gold badge mine!
 
The executable has 30MB!
 
Xeo
@MooingDuck No, the scope doesn't even end
It's just BOOM, stack gone
 
@RMartinhoFernandes Once more, with L.
 
11:12 PM
@Xeo oh right, exit, sorry. I was thinking it unwound like an exception.
 
Xeo
@RMartinhoFernandes Why two?
 
@Xeo See the one about the pointers.
 
Xeo
Yeah, that's one, I linked it
Mine is not even close
 
Oh wait.
Right.
 
Xeo
+20
 
11:14 PM
hehe - fun question

http://math.stackexchange.com/questions/102598/100-soldiers-riddle
 
WOAH, the executable RUNS.
Crashes almost immediately, but still.
 
Falling after two steps still counts as running!
 
(gdb) bt
#0  0x753da064 in msvcrt!memmove () from C:\Windows\syswow64\msvcrt.dll
#1  0x753da00b in msvcrt!memmove () from C:\Windows\syswow64\msvcrt.dll
#2  0x005a22fd in std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_float<long double> ()
#3  0xda4d5900 in ?? ()
Backtrace stopped: Not enough registers or memory available to unwind further
And hence ends usefulness of a debugger.
 
@FredOverflow mind if I edit the answer so the std::string is allocated in a buffer so it has dynamic duration to avoid potential UB, and mentioning boost::optional?
 
But SDL works and all, so I count this as a success so far.
 
11:16 PM
@MooingDuck If you do, make you sure you align things properly this time ;)
 
@RMartinhoFernandes I was going to look it up again :(
it's a big enough change though that I wanted to get permission first, and he hasn't responded or fixed it himself.
 
Xeo
Wow, the comments on the pointer question...
Someone shoot that guy.
2
 
as per stackoverflow.com/questions/9026640, ouah observed if you call a function, local variables are not in the current scope for the duration of the question. It's not destructed, but it's not in scope either.
 
Of course not, if it was you could refer to it.
C++ doesn't have dynamic scope or whatever that abomination is called.
 
@RMartinhoFernandes pass by name was a bad idea too
 
11:25 PM
miserable: I feel it
 
wish google calculator could do logarithms in arbitrary bases
 
@MooingDuck Please provide your own answer for that.
 
@FredOverflow can do
 
@MooingDuck log_b(x) = log_c(x) / log_c(b)
 
@RMartinhoFernandes It always takes me a bit to remember which bit goes where. Easier to open excel
 
11:28 PM
Sigh.
 
Why does a C++ beginner work on super-secret project?
Probably the next gen compression algorithm or something :)
 
Shortage of evil overlords?
 
Although I cannot imagine how killing off stack variables prematurely and storing pointers in strings would help achieve any significant goal.
 
You're not clever enough!
I wrote something with CMake and it works.
Now that's a mystery.
 
@Xeo Damn, this thing doesn't build.
./src/future.cpp:42:10: error: value of type 'std::__1::future_errc' is not implicitly convertible to 'int'
Do you happen to know a revision that builds?
 
Xeo
11:31 PM
libcxx?
 
Xeo
hm
 
When I saw that title, my first intuition was to link to the C++ book FAQ :)
> Fred, you are being overly nice by letting people know there is placement new - they might start using it ;)... The answer should've been "no, you cannot".
Hmm... do you guys think I should delete my answer?
 
@Xeo Function template or class template?
 
Xeo
@LucDanton class template, inheritance, using declarations... solve that with the "indices trick" :)
 
11:39 PM
I tend to not hit walls with variadic packs when it comes to strictly metaprogramming as opposed to the variadic function templates of generic code (and I strike down those walls with indices).
 
Xeo
Well, if pack expansion was "smarter", then we wouldn't need the huge amount of recursion in some templates
like a variadic and_<is_same<A,B>, is_integer<C>, ...> template
 
Oh. I first express the algorithm using recursion then express it in C++.
 
Xeo
Needs recursion because pack expansion is dumb
template<class Cond, class... Tail>
struct and_v{
  static constexpr bool value = Cond::value && Tail::value...;
};
would be the ideal version
With && Tail::value as the pattern
 
I don't see a problem with that template. Do you mean the hassle of writing a specialization?
 
11:45 PM
isn't 2001: A Space Odyssey supposed to be a very good film?
 
Xeo
@LucDanton Yes.
And recursion
 
@DeadMG You'll probably find it boring as heck. Because it is.
 
yeah
 
But the book is awesomez.
 
11:45 PM
Ah well. In my head I expressed the recursion with a base case, then implemented in C++ using a specialization :)
 
I watched like the first half an hour and I was like, you could have fucking cut every single scene here and I'd not have noticed
 
Xeo
@LucDanton Yeah, but recursion can really suck. See this.
 
What's the problem with recursion?
 
Xeo
@RMartinhoFernandes Recursion limits
 
1024 on GCC. I'm not sure I'll hit that often.
 
11:47 PM
@DeadMG I think it's supposed to showcase a lot of filming techniques, among other things. But those things alone would not make a good film. I've always thought that it's the kind of film for that, but I've never seen it (I'm quite content with the book, too).
@Xeo Oh I see, no wonder I don't hit those kind walls, that's not metaprogramming.
 
@Xeo what did you build libc++ with? Clang 3.0 or your trunk build?
 
Xeo
@RMartinhoFernandes Uhh.. I just ./buildit
I think it used GCC
 
Here it uses clang++.
 
I think I've deliberately shied away from variadic templates (that are not related to TMP), since it does get ugly. I delegate as much as possible to std::tuple, but I did have to get my hands messy for overload and related things.
 
Xeo
@LucDanton It only gets ugly because pack expansion is dumb. :/ I hope they get that "fixed" in C++1y
 
11:51 PM
@DeadMG Did you do anything else while watching it?
 
not really
 
@LucDanton Those indices should be in the standard library.
 
Xeo
@KerrekSB Many things should be there.
 
@Xeo Or conversely, std::tuple doesn't have enough functionality :)
 
@Xeo std::ld::indices
 
11:52 PM
ARrrgh, I manually fixed that error but it wasn't enough.
 
@DeadMG Well, I'm not fanatic about the film, but I like it. It's very slow, though.
 
Fuck this, libc++ from trunk doesn't build with clang from trunk.
 
Speaking of shamelessly currying favours, would anyone like to upvote my Baby's First Tuple? That way I could cross the %100 barrier before midnight :-)
 
Xeo
@RMartinhoFernandes Hm, did for me
 
@LucDanton Did you know std::array and std::pair are also tuples?
 
Xeo
11:53 PM
@KerrekSB They offer the "tuple protocol"
 
@Xeo Can you check something for me? On <future>, is future_errc a scoped enum?
 
@KerrekSB Yes.
 
is <future> 4.7?
 
I've never had an instance of using an std::array like a tuple though.
 
Apart from "more indirection", "making it a tuple" probably solves 90% of the remaining problems...
 
11:54 PM
Heh, guess I can add that to my unit tests for apply_tuple.
 
@kfmfe04 Yes.
 
@LucDanton Quite.
 
Xeo
enum class future_errc
{
    broken_promise,
    future_already_retrieved,
    promise_already_satisfied,
    no_state
};
 
But there's a switch(an_int) { case future_errc::broken_promise: ... } in future.cpp!
That can't compile.
 
Xeo
@RMartinhoFernandes line?
 
11:57 PM
Can the WndProc of a window ever be executed in a thread other than the thread that created the window?
 
@SethCarnegie I doubt it
 
Great, it works like a charm.
 
it's not called the window procedure for no reason
 
@TonyTheLion I need to be sure, my use of critical sections depends on it
I doubt it too, but I'm not sure
 
11:59 PM
@SethCarnegie I'm not entirely sure, so I think it might deserve an SO question
 
@LucDanton Perhaps TOP is the Next Big Thing after OOP
 
Xeo
@RMartinhoFernandes Hm, I have that too
 
I try to avoid yes/no questions on StackOverflow, but I guess it does
 
@Xeo Maybe the clang you used at the time didn't check that?
Anyway, I fixed everything and it compiled now.
 

« first day (467 days earlier)      last day (4467 days later) »