« first day (137 days earlier)      last day (4819 days later) » 

sbi
5:43 AM
@JohnDibling My idea of "exciting" doesn't necessarily include "dying". Also, I like to read, and I have very little time for it - except when I commute. Sitting in the car two hours a day would be really dreadful. Reading while someone else drives is much, much nicer.
 
 
2 hours later…
7:31 AM
@sbi everyones idea of exciting includes the prospect of dying.
http://en.wikipedia.org/wiki/Micromort
You are always making a choice based on the relative risk of being... terminally damaged... by the activity
 
 
1 hour later…
8:52 AM
when I have the following:
	bool start()
	{
		m_ULThreadHandle = _beginthreadex(NULL, 0, tfunc, this, 0, &m_UIThreadID);
		return (m_ULThreadHandle != 0);
	}
where m_ULThreadHandle is of type unsigned long
and then I have
	void kill()
	{
		TerminateThread((HANDLE)m_ULThreadHandle, 0);
	}
what happens to the thread handle, do I have to call CloseHandle on it after TerminateThread?
question is, does kill() leak the thread handle?
 
did you look at the docs?
 
I did
it says that the thread object stays alive until all handles are closed to it
it doesn't explicitly say that I should call CloseHandle after calling TerminateThread
 
If you do not close the handle, how do all handles get closed? -- also googling for "TerminateThread CloseHandle" reports a good amount of hints, so it seems as if they are usually executed one after the other
I don't know whether MSDN contains sample code programs, but that would probably be another good source of information
*the handle returned by _beginthreadex() has to be closed by the
caller of _beginthreadex()*
 
As with all handles
they remain open, until closed, via CloseHandle
TerminateThread merely terminates the thread that the handle represents
There could be many handles that refer to that thread.
All the thread handles, including the one passed to TerminateThread, remain valid, until closed
 
9:08 AM
Uhm... I don't know anything about windows development, but it seems from the article I just linked that you do not always need to close the handle, that it depends on the API that you are using:
*_endthread automatically closes the thread handle (whereas _endthreadex does not). Therefore, when using _beginthread and _endthread, do not explicitly close the thread handle by calling the Win32 CloseHandle API. This behavior differs from the Win32 ExitThread API.*
I do agree, though that with _beginthreadex and TerminateThread, you do need to close it
 
9:36 AM
@david how does it differ from the behavior of ExitThread. ExitThread does not take a thread handle, and doesn't close any thread handles.
If you called beginthreadex and didnt close the handle, and the thread later terminated via ExitThread, the thread handle would still need to be closed
 
9:48 AM
what differs is the _beginthread/_endthread (without the ex suffix), in that case you do not need to close the handle
 
how hard could it be to wrap that up? i'm almost considering suicide. who can live in a world of people you can't look in the eye and see a someone in there, only a primitive rule-based knowledge system?
 
@alf having a bad day?
I think the core of that is, you can't tell the difference between people and rule based knowledge systems
or, put it another way.
how would you prove you wern't. just a rule based knowledge system
 
10:04 AM
@ChrisBecke some. my brother-in-law is one of handful conscious human beings i have encountered. and i'm like 48 years old, met a lot of folks high and low
 
I have difficulty proving to myself that im concious.
conscious
 
@ChrisBecke depends on definition of "is". if rule based system is turing complete then anything "is" a rule based system for a sufficiently broad definition of "is".
 
or on the definition of conscious
what is the difference between a conscious and a non conscious rule based system.
 
@ChrisBecke the conscious system has a sense of humor
 
or, at what point does it become a moral crime to hit "stop" in the debugger :P
rubbish. humor is an evolved trait that confers a survival advantage to rule based machines that exhibit it.
so, consciousness is not a requirement for humor.
 
10:14 AM
it's my definition. i think anyone able to understand my jokes must be conscious.
the rest are, of course, robots
that link is an example, by the way
 
I, Robot
 
i thought i posted link to Metallica's "kill 'em all", but the robot posting that vid had not understood the concept of quality, and added non-quality things
and so for many other version of that
 
I think that the only difference between a conscious and non conscious rbkm is that the non conscious one could never realize that it can't prove its conscious.
 
10:30 AM
@AlfPSteinbach, back to GEB
 
Hi all
I just read that I can simply tell my compiler which template instantiations to make to avoid linker errors with templates
I found the syntax for templated functions, but not for templated classes
how would I do that in this case?
 
yeah well that's a templated function
What about classes?
 
Just try this (I have not done this for ages, so I am playing by the ear):
template class Foo<int>;
 
@Nils you really don't want to go down this path
 
10:40 AM
So what's your suggestion then?
 
The keywords to google for is "explicit template instantiations"
 
@Nils suggestion for what problem?
 
that is not a problem
what is the problem you are solving where you attempted to use template instantiations?
 
And the same comments that I did yesterday still hold today: you only want to do this when you want (or are willing) to limit the set of types that can be used to instantiate your template
 
10:42 AM
And it won't work if you aren't able to instantiate implicitly at that position.
 
Right, I had to reread it so I am going to re state it in a different way:
to be able to explicitly instantiate a template, the template has to be defined at that point in the code (i.e. an implicit instantiation would also work)
 
@DavidRodríguezdribeas Thx for your comment, but that's what I also read on C++ faq lite. What about templated classes, how do I "instantiate" them?
 
@Nils You instantiate them as shown in this comment (a few lines above): chat.stackoverflow.com/transcript/message/407415#407415
 
0
Q: How to get IOStream to perform better ?

Matthieu M.Most previously C-users prefer to use the printf / scanf family of functions even in C++. Although I admit that I find the interface way better (especially POSIX-like format and localization), it seems that an overwhelming concern is performance. Taking at look at his question: How can I sp...

 
ah didn't catch that
 
10:47 AM
@AlfPSteinbach your tutorial on pointers is very impressive :)
 
Some other differences that you might not be aware of: when explicitly instantiating a class template, all member functions are instantiated --when instantiation is implicit, only those member functions that are actually used will get instantiated.
@Tony Care to share a link?
 
How can I compile something into an object file with g++, so that it doesn't complain about the lack of a main function?
 
g++ -c foo.cxx
 
@DavidRodríguezdribeas So according to you I would just have to add template class Foo<string>; to Foo.cpp in codepad.org/iPnfAfYm ? But it doesn't work here.
@wilx thx
 
sbi
11:03 AM
I'm having bad problems connecting to the chat through FF, and while I'm able to type this in IE, IE had trouble connecting to the chat, too. Is this on my end?
 
chrome here
 
@sbi: I am using FF right now. It sounds like the problem is on your end.
 
Btw is there an article dealing with this template problem extensively? I just read C++ faq lite so far.
 
sbi
Ah, thanks. <sigh/>
 
There is a whole book about templates.
C++ Templates - The Complete Guide by David Vandevoorde and Nicolai M. Josuttis
 
11:06 AM
@Nils I am not sure what you are doing there, but believe me it works. I have used it in the past and I just tried a simple example
 
so you just add this line and then type g++ -o bar Bar.cpp ?
 
@Tony over hundred pages?! this has got to go pretty deep
 
Adding "template class Foo<string>;" at the end of Foo.cpp and compiling/linking all together: g++ -o test Foo.cpp Bar.cpp should compile appropriatedly
 
ah at the end, added it at the top
yes
now it worked! Thanks a lot @DavidRodríguezdribeas
Now if I have a class which derives from a templated class, but specify the template argument explicitly when deriving I still only manage to compile it when I put everything in the h file.
err I mean link, it compiles
 
I have yet to actually try to derive from a template bass class...
 
11:32 AM
and yes of course the class used as a template argument is a templated class itself
 
12:10 PM
@ina you can do as it says, (1) close visual studio, (2) delete the [.sdf] file, (3) re-open the solution. it takes some time to re-build the browsing database.
@ina well, it may also be as it says that SQLServer 3.5 isn't installed. If it is required it should have been installed along with Visual Studio. So if deleting [.sdf] does not work, try to re-install Visual Studio.
 
12:28 PM
@Nils This is what AProgrammer stated at 10:42, and I tried to restate to make it clearer a little later. What is clear at the end is that we both failed to clarify!
@Nils Uhm... I am failing to understand your exact situation, maybe some code would help there.
 
@Nils, do you understand what is meant by "instantiating a template" ? You seem to be lost because a lack of background information about how c++ handle templates.
 
 
2 hours later…
2:20 PM
0
Q: template to return specific type

TonyI have a template function that I wish to return either the type of T or a variant. I tried to do as follows, however the compiler complains it cannot convert 'variant' to int (where I use this function with T=int). How should I implement this so I can either just return the variant or the type...

anybody care to help me out?
templates not really my thing quite yet
 
On a Linux environment where exactly is the name of a library to which one can link with -l defined?
 
er /usr/lib ?
 
so it's the filename?
I don't think so?
 
-lfoo is mapped to some libfoo.a or libfoo.so file.
Where exactly depends on many things. Is is likely either in /usr/lib or in /usr/local/lib.
 
so it's the filename w/o the ending?
if I add -L /usr/blah and if there is a file called libblah.so then -llibblah will work?
humm but for math it's just -lm
I guess it's also expected to have a lib prefix
is this documented somewhere?
 
2:31 PM
@Tony I have upvoted the first answer, there are other approaches, but that one seems the most sensible one: just create a function that looks up the variant version and add a wrapper that will apply the get<> to that
then calling code can decide which version they want to use
this moves the most internal if to user code, but think of it: it is just reasonable, user code must already know what type it is trying to get! when it passes the boolean
@Nils from "libXXX.{a,so}" you will just pass -lXXX
 
ic
 
@DavidRodríguezdribeas yea the user code will know when it wants to get the variant itself or the type inside the variant
so how do I define the function specialization? template<> variant find_attribute?
 
Don't specialize the function, provide a templated for the particular type, and a non-templated for the variant:
const VariantType& find_attribute(const std::string& attribute);
template <typename T>
T find_attribute( const std::string & attribute ) {
return boost::get<T>( find_attribute( attribute ) );
}
More often than not, specialization of template functions is not a good idea
 
oh I see
is there some place that explains why that isn't a good idea?
 
note that if you specialized, the user code would have to do:
find_attribute<VariantType>( "attr" );
to call the variant version, which is not really nice...
google for it, there are not that many differences... I remember that litb had an answer that treated some parts of it, I think around 1.5 years ago in SO
not that this will help much narrowing the search
 
2:43 PM
thankx for the help :)
 
2:54 PM
@DavidRodríguezdribeas thx for responding but I fixed most of my problems now, I think they were mostly related to a confusing build sys
stackoverflow.com/questions/5155155/… lol nobody seems to know that..
 
 
2 hours later…
sbi
4:43 PM
...in the ensuing silence, a needle hit the floor with a bang, its rebounces sending thuds across the room that hit the walls like ripples hit the shore of a lake of liquid lead...
 
uh, wot
 
5:01 PM
... he stabbed his heartless breast with his shaftless knife, and fell to earth with a silent boom
 
 
1 hour later…
6:20 PM
suppose i do if(f(x) == 3 || f(x) == 5) {...}. can i expect the compiler to optimize it and don't call f() twice?
 
no
maybe if the code was inlined
but that's pretty unreliable
you can't expect or depend that it will be, but it might be
 
sbi
@BlackBear That depends on whether the optimizer can verify that calling f() doesn't produce any visible side-effects. Why don't you write it whichever way is easiest to read and profile if you have a performance problem?
 
@sbi I haven't performance problems, but I'm writing this kind of thing quite often, so I was wondering..
 
@BlackBear you could always store the result of f(x) then compare the stored result
 
@thecoshman ok thanks :)
 
6:34 PM
or use a switch statement, `switch(f(x)){case 3: case 5: /* your code / break; default: / not 3 or 5*/ }
 
sbi
@BlackBear My preference would depend on what f() really is. If it is v.end(), I wouldn't look twice. However, if the name might suggest that there's side-effects, I would wonder about the correctness of that code.
 
@sbi it probably hasn't (it's a library function) but i can't know it for sure
 
sbi
@BlackBear Then how can you be sure whether it's not a bug to call it twice? Sounds wrong to me.
 
man
I hate team coursework
and PHP
 
so what else is new? :D
 
6:50 PM
nih novi sub sole
 
Why people insist on using PHP, I'll never understand.
 
@PiotrLegnica it's quite a nice language to use for getting into web dev stuff I found. For a new person it is fairly forgiving whilst letting them get to grips with program flow and so forth.
What you got against it?
 
@thecoshman Well, everything. It's pain to write, thanks to weak dynamic typing, inconsistent grammar and mess instead of standard library. It's pain to deploy, thanks to php.ini, shared-nothing architecture and brain-dead "security" features.
Granted, there are alternative interpreters/compilers, but in most cases you have to target them specifically.
 
7:05 PM
@PiotrLegnica: I dont see why you're so surprised
 
Also everything teaching PHP is written by people who have no idea what the hell they are talking about, spreading things like "your webapp doesn't work? Oh, you have to chmod 777 everything".
 
if you're incompetent, and you design a language for incompetents, then incompetents will happily use it
 
Calling PHP designed is an insult to language designers. :P
 
lol @jalf
 
yeah but any sane language designer would consider the existence of PHP to be an insult anyway
 
7:10 PM
My favourite bit is that you can do $array[]() but cannot do function()[] (also, whoever thought sigils were a good idea...).
 
@PiotrLegnica I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way. -- Rasmus Lerdorf
@PiotrLegnica sigils work in a templating language, including php's string interpolation
that's the least of the problems
 
 
1 hour later…
8:19 PM
I don't get it. To me it's no different than Visual Basic. Both have their uses, but why are you using Visual Basic when you can do it in C++.

Well, if I can do simple stuff easily, why pick a language that requires more work?
 
pretty much that
C++ is way easier to use than PGP
PHP*
 
sbi
Jan 29 at 22:35, by sbi
You can edit your messages for 2mins. Click the v arrow appearing left of it when you hover your mouse over it. Also, cursor up will edit your last message, Enter confirms, Escape cancels this.
 
it's a chat
you don't edit your messages in a chat
 
It's a chat with magical powers.
 
sbi
@DeadMG Yes, I do!
 
 
1 hour later…
9:40 PM
I find PHP extraordinarily easy.
Because I don't try to make it do anything complicated.
A quick poll, or collecting info for an email.
Secure login..... uh... no.
 
Knowing more than one language, I can say that PHP is not easy.
 
Relatively easy, maybe not, if there's a language that can do things simpler.

But looking at it alone, it's not complicated.
Not any more so than Visual Basic.

Unless you're trying to make it something it's not.
I wouldn't run around claiming it's a stand-alone solution to build a dynamic website.
But to simply collect information and send it somewhere when there's no concern over the security of said information..... I don't see how it can be that complicated.
I can get it to do that in a few lines of code.
 
10:00 PM
@PiotrLegnica really? like @Xaade said, I never tried to make it do anything too complex, and works really well for that in my opinion
Use it things like passing form data, getting data too and from a DB for a web page
 
10:23 PM
ok, is it just a weird thing that Visual Studio does? if define enum test{ a, b, c }; I can in my code later on go test::b so that I know I am getting the value of b from the test enumeration rather then some other 'b'. Sure I used bad variables name for this example, but my point is still the same
I think I might have been smoking something with that one :S
 
It's not standard in 03.
 
is in 0x though
 
@DeadMG That's cool
It's very nice when you have code hinting on, saves you having to check up to make sure your getting the right value
 
Yeah, 0x is awesome. Shame they didn't push modules through. :(
 

« first day (137 days earlier)      last day (4819 days later) »