« first day (395 days earlier)      last day (4546 days later) » 

9:00 PM
so for example a static vector needs to be deleted, but a static int not?
 
it doesn't need to be deleted...
nothing needs to be deleted...
when your program terminates, then by definition your program cannot leak anymore
 
@bamboon You need to learn about the difference between the stack and the free store.
 
@JohannesSchaublitb you confuse me now
@StackedCrooked obviously yes, you know a good resource, beside wiki?
 
30
Q: Proper stack and heap usage in C++?

AlexanderI've been programming for a while but It's been mostly Java and C#. I've never actually had to manage memory on my own. I recently began programming in C++ and I'm a little confused as to when I should store things on the stack and when to store them on the heap. My understanding is that variabl...

@bamboon But you really need to learn the basics from a good book. For example:
 
@StackedCrooked that book is lying in front of me
 
9:05 PM
@bamboon Then read it! :)
And do the exercises!
And ask SO if you don't understand something.
 
does it teach the static initialization order fiasco?
 
Or ask here. But only if we are in a good mood.
 
i am doing them
 
@JohannesSchaublitb actually, I don't remember it being mentioned in that book.
 
but actually it isnt really explaining the technical stuff like heap or stack (at least till chapter 12)
 
9:07 PM
It's a bit outdated, it teaches how to automate memory managent using COW for example.
@bamboon It can't teach everything right from the start..
 
yeah, thats why I ask here
 
That's good. And you got an answer.
 
it doesn't need to explain "heap" or "stack". it needs to explain "dynamic storage duration" and "automatic storage duration"
 
but it taught me that I have to delete everything which I created with new, otherwise we have mem leak, and now you guys tell me, I have to delete nothing. that confuses me
 
@bamboon don't listen to Johannes :p
He's right, but he's also wrong.
@bamboon Just trust the book. You need to delete every object created with new.
 
9:11 PM
^^i think I will forget it for now
I like the book very much
 
@bamboon I learned C++ from this book back in the winter 2004 - 2005.
 
pretty much nobody ever uses delete
like, ever
 
After that I read Effective C++, which I also recommend.
@DeadMG You think... Ever seen my company's codebase?
 
@StackedCrooked no
 
how many decades old is it?
 
9:14 PM
leaving an object un-delete'ed is entirely fine
the OS will reclaim any memory
 
@JohannesSchaublitb Ha, I won't show you either!
@DeadMG I think development started around 2003.
 
@StackedCrooked huh
 
eh
that's probably before the shared_ptr revolution
 
@StackedCrooked effective c++ is just lying behind me but I think it is still little to high for me^^
 
and certainly before useful unique-ownership pointers
 
9:15 PM
@DeadMG They still don't know about RAII.
 
ok
so development started about 2003, but the code is written in the style of 1993
or even 1983
 
@DeadMG I introduced the concept of a scoped lock to them. They were using posix lock and unlock functions in combination with exceptions all over the place. Poor lads.
 
@DeadMG I think unique ownership is a pretty late concept. In the early 2000 copy-on-write seemed to be in fashion.
 
yeah
until concurrency happened
 
9:22 PM
Then party time was over.
And the cows had to leave.
 
qt still uses COW
 
sleep: I require some
 
and it seems to be successful even with multithreading
 
sbi
@StackedCrooked I was once in such a company. I was young then, and had a lot of energy. So I found me some allies and set out to change them. It took more than half a decade, but when I left, they had become much better. Nowadays, I would simply look for a different job. I have kids to spend my energy on.
 
@JohannesSchaublitb I believe it can work well, but I don't think it's a superior practice.
 
9:23 PM
there is no way that it succeeds with multi-threading
have you seen the numbers Herb put in his GotW? It was like, two entire factors slower to use CoW in a concurrent environment even in simple ways
 
sbi
@DeadMG Of course there is. Just lock everything.
 
@DeadMG It can use a mutex-protected pimpl.
 
that can only make it "correct", that can't make it remotely performant
 
sbi
@DeadMG If you are making a GUI, a factor of 10 might be irrelevant. Whether a button I click on takes 5msecs to react or 50msecs simply doesn't matter.
 
not to mention that some, or even many, interface functions require a lock between calls on top of the per-call lock
anyway, I srsly require sleep
nighty night
 
9:25 PM
Night.
 
Hey guys
 
watching football
 
At one company we had this function void InvokeLater(boost::function<void()> fun);. It pushed the function object as a post-message on the main tread's message loop were it was eventually invoked. It was a mechanism that allowed using worker threads safely without requiring mutexes and locks. (Provided that each worker thread maintained its own state without touching the rest.)
 
it's what I like with qt. you can execute slots like that
it'S very easy :)
 
any dutch guys in here?
 
9:30 PM
@bamboon Flemish.
 
sbi
@JohannesSchaublitb Who plays?
 
Germany vs the Netherlands?
Cool.
 
sbi
@JohannesSchaublitb Oh. Which channel is that on?
 
GER is rocking
 
9:33 PM
GER plays, NED screams
 
sbi
(I don't have a TV, but I can watch online.)
 
ZDF
but ur late xD
 
you have 1 min left
^^
 
sbi
Oh. Story of my life. :)
 
Hey, can you guys think of any smarter way to express all the strings consisting of the symbols ’a’ and ’b’ that have an odd number of ’a’s and an even number of ’b’s.

Right now all I can think of is
((aa)*(bb)*)* a ((aa)*(bb)*)*
 
sbi
9:35 PM
@JohannesSchaublitb They have all the goals cut together in 2mins. What more do I need to see? :)
 
@Cat: why would you expect that transform_if would do something different than copy_if?
 
Because of the name.
 
@CatPlusPlus Nice answer.
 
How so? transform and copy are nearly the same thing.
 
9:36 PM
Something like transform_filter might be better.
 
I guess (aa|bb)* a (aa|bb)* would be the same
 
transform is map.
 
Not necesarrily.
 
ok good night, thanks for the help
 
sbi
Oh, only two goals. :)
Nice ones, though.
 
9:38 PM
Well, filtering behaviour just don't come first to mind when I read transform_if.
 
3 actually
 
What comes to mind when reading copy_if?
 
Copy if predicate is true.
Transform if predicate is true.
 
Exactly.
 
See, it doesn't mean the same thing.
 
9:39 PM
Sure it does -- at least the "if predicate is true" part
 
sbi
@bamboon Indeed! Was there one in the last few minutes?
 
And remove_copy_if should have been named copy_unless.
 
I don't read transform_if as map . filter, it's just that.
 
Interesting, OK.
 
@sbi no, i think min 70 or such
 
9:42 PM
@StackedCrooked remove must be one of the worst named things in C++.
 
sbi
@bamboon Yeah, I just saw it. Pretty nice game for the Germans, it seems.
 
I feel I should get dust off my so-called blog. Maybe I'll move to a fancy static file generator setup.
 
@sbi yeah, but Dutch guys didnt really fight back
 
sbi
@bamboon Yeah, so it seems. But you'll have to admit that the goals were played pretty good.
 
of course, chances are good for EM
but still a while to go
 
sbi
9:52 PM
@bamboon Yeah, that's certainly true.
 
well bed is calling
cya guys
 
Don't answer!
 
sbi
Good night! See you!
@CatPlusPlus Why not? If I don't refer to his message, I won't keep him from going to bed.
 
@sbi Because beds are not supposed to be using phones, it's some fishy business!
 
sbi
@CatPlusPlus Oh, you were referring to him. Well, you might have made that explicit, which would have given me a chance to understand that.
 
9:57 PM
Your network is off, my message was before yours.
 
sbi
@CatPlusPlus You could still have referred to us, rather than to him.
 
@sbi I would. And I don't really see how Jeff being a moron changes anything
 
sbi
7 hours ago, by Cat Plus Plus
It'll get removed by a humourless mob anyway, but I can say I tried.
 
10:28 PM
Dammit, heating is not working very well. It's cold. cold. cold.
 
Excuse me guys
Have you used regular expressions ?
 
I'm having an assignment in school and I don't know if it's miswritten, because the regular expression I'm trying to create for converting to an NFA is really nasty!
The question is: Give a finite state automaton (deterministic or non-deterministic) that accepts all the strings consisting of the symbols ’a’ and ’b’ that have an odd number of ’a’s and an even number of ’b’s.
this means that,
bab,
bbabb,
bababab,
bbababa
and a bunch of nasty strings are allowed
 
Could someone shed some light on why there's no conversion sequence in the following situation: struct A { A(std::string); }; A a = "hello";
Direct-initialization is OK (A a("hello");), but copy-initialization, and also passing a function argument, is not.
(I.e. f("hello"); for void f(A);)
 
Do you find a way to solve this easily? This is actually the first question of a hand-in. I believe what they mean is to give an NFA of a language that accepts odd number of a's followed by an even number of b's.
 
10:40 PM
@ManofOneWay You could try and be recursive: shave off an even number, like, aa, bb, abab or baba, and then check if the remainder is valid.
 
@KerrekSB I found this expression on stackoverflow (aa|bb|(ab|ba)(aa|bb)*(ba|ab))*(b|(ab|ba)(bb|aa)*a), defining the language of any odd number of b's and even number of a's. So the exact opposite. To create an NFA out of that just don't make sense? Here is the actual question, stackoverflow.com/questions/3698625/…
 
Many ways to skin a lion...
@CatPlusPlus: ping
 
I don't do NFAs.
 
@CatPlusPlus No, I was wondering if you had an opinion on the string conversion.
I'm moderately baffled.
std::string doesn't have an explicit constructor. Why doesn't A a = "hello"; find the matching conversion?
 
10:58 PM
Dunno. Works in MSVC.
 
Ugh. Mac OS X has its own quirky little way of setting documentation directories.
So I have to use git --help or look it up online every time. -.-
 
Well, OSX sucks, what's new.
 
Yyyep.
 
@CatPlusPlus Seriously? That's just plain odd. I'd imagine that in a crunch GCC is more faithful to the standard, but I can't explain this one...
 
10
Q: C++ implicit conversions

Several comments on a recent answer of mine, http://stackoverflow.com/questions/862858/what-other-useful-casts-can-be-used-in-c/862896#862896, suggest that my understanding of C++ conversions is faulty. Just to clarify the issue, consider the following code: #include <string> struct A { ...

@KerrekSB might help
 
11:03 PM
@cHao Awesome, thanks!
So GCC is doing it right after all :-)
 
:D
 
@cHao I updated my answer with this information. Thanks again!
Now I wonder why the direct-initialization is OK, though. Does it not count as a conversion if the value is directly forwarded to the argument type's constructor?
 
which direct initialization are you talking about?
 
A a("hello");
I suppose that constitutes explicit conversion, so there's one level of implicitness from char(&)[6] to string, and then one explicit conversion from string to A.
 
calls the std::string constructor, and passes the string to A's constructor
from the looks of it
 
11:12 PM
Actually, the restriction only applies to user-defined types, so you get the fundamental conversion from char(&)[6] to const char * for free.
There's quite a lot to this, as it turns out :-)
 
so it seems. :)
 
I suppose the one-conversion rule makes sense. Anything else would no longer be definite. If you could go from X to A and from A to W, and also from X to B and from B to W, then it would not be clear what happens.
Being explicit (W w(B(x));) is OK, but implict (W w(x);) is out.
 
0
Q: Segmentation Fault Fail?

DarthVaderProgram received signal SIGSEGV, Segmentation fault. [Switching to Thread -177935456 (LWP 5483)] 0xf79ff2ca in activemq::core::ActiveMQSessionExecutor::dispatch (this=0xf4b04bc0, dispatch=@0xf564e240) at activemq/core/ActiveMQSessionExecutor.cpp:129 129 activemq/core/ActiveMQSessionExecutor....

What a question.
 
@Maxpm I definitely don't want more code.
It can only go down from here.
 
Oh God, it's from that guy I answered before.
Where I accidentally put static functions in a namespace.
 
11:30 PM
hiyas
 
Hello!
 
guys i had a quick question. do you know how i can export functions from my static library into a dll (via wrappers) so that my exe can see it?
 
So you want to compile a DLL that has functions that wrap other functions from a static library?
 
at the moment it seems like the dll which has the wrapper function can't seem to find the static lib function even though i am putting it as a dependency for the vs2008 dll project
yea the dll is exporting functions aka wrappers which call static library functions
 
I haven't coded on Windows in a while, but I'm pretty sure you're doing the right thing.
What do you mean when you say it's not finding the static lib function?
 
11:34 PM
well in the wrapper
i make a call to the static lib function
 
So it's not compiling?
 
and it seems like the exe that is calling the wrapper/exported function functionality works as in there are statements that i coded in the implementation of that wrapper which print
but when i make the call to the static lib
for that function
it does not call it
it is as if it can't see it
 
Huh. I see.
And nothing is crashing?
 
nope
compiles and links
 
Have you tried setting up a dummy function that returns void and has no arguments?
Just to print something out in both the dynamic and static library?
 
11:36 PM
i am using implicit linking not explicit. no getprocess calls etc.
yea i have a test function in the static lib
but it has some args
it does some file i/o etc
but prints stuff to screen as well. then i just used the wrapper to call it
but nothing happens
as in nothing prints
i got the dll export viewer
and in there i see the correct exported functions which is fine because that is the behavior
but i don't get visibility from the static lib side
so i have no idea what i am doing wrong when i make that call in the wrapper.
 
I remember I had problems with linking where the project settings were not the same for the library and executable.
 
let me show u what i found...
i found this on ms support site
i dunno if this means that i have to expliciting tell the linker
to link to that function
btw everying is release version so there is no issue there either.
i just can't seem to get my dll to link to the static lib it seems.
even though in vs2008 allu have to do is drag and drop that static lib.
 
Can you get the executable to link to the static lib without the dynamic lib middleman?
 
u mean by calling the static lib directly?
 
Yes.
 
11:42 PM
i can try that
that works
so the lib is working just fine
now the issue is how to get the dll to see that static lib...
maybe this is a linker issue?
 
Hmm.
I'm really not sure. You could always try starting from scratch, though I imagine that's not ideal. Sorry.
 
i saw some questions about that
in stackoverflow
but no one answered the question
no idea at this point how to get my static lib to see the dll
did you see that support article?
do you think ih ave to explicitly
use that #pragma comment linker (/export ?
 
You really shouldn't have to.
 
i use the extern c to avoid name mangling
 
But I'm not a Windows expert.
 
11:50 PM
yea i am stuck crap. dunno what to do. do youknow how i can get this answered?
i am been hunting google...forums
 
Assuming you have a question on the main site, I can add a bounty in a couple of days.
 
well i appreciate you at least talking to me
i will try to find some windows related lib management
and see if there is anything else i can try
 
Good luck.
 
thanks!
 
:)
 
11:53 PM
Good std::time_of_day.
3
Anyone have an interest in hardware tinkering?
1
Q: Is it possible to control LCD components in software?

MosheIs it possible, say, using a programming language like C or C++, to write a program that directly interacts with the power inverter or controller in a modern LCD monitor? I'm told that it used to be possible to forcefully overclock the oscillator in a CRT to make it catch on fire. I'm curious if ...

 

« first day (395 days earlier)      last day (4546 days later) »