« first day (34 days earlier)      last day (4899 days later) » 

12:01 AM
gnight FredOverflow
 
@FredOverflow Good night.
 
12:25 AM
@FredOverflow Good night!
 
@JamesMcNellis Too late -- he's been asleep for half an hour now.. :-)
 
@JerryCoffin Nah. I'm just early for tomorrow!
 
good mornin
 
cant sleep damnit!
 
12:38 AM
@JerryCoffin Ha! I was not too late after all!
 
@tina i checked, and there is a GIS chat room. however, no people there...
@tina the message i posted has a clickable link
@tina you might check if the creator of that chat room, Marc Gravell, can help you
 
2:00 AM
@tina that's great
 
what is the point of [c++-faq] at stackoverflow.com/questions/4221163/…? can someone explain what that question is even asking? (I completely don't get it)
(commented to the OP indirectly asking for more information, but no response to that yet)
 
2:17 AM
good night everybody
 
 
4 hours later…
sbi
6:13 AM
@FredNurk I had a shot at it. It's a long shot, though:
0
A: Virtual inheritance and static inheritance - mixing in C++

sbi How could you implement class A such that if B has a virtual override, that it is dynamically dispatched, but statically dispatched if B doesn't? As others have noticed, it's really hard to make sense of that question, but it made me remember something I have learned a long time ago, so here...

 
I think you're misunderstanding him (but I'm not completely sure)
he's using CRTP rather than specifying a base for A as a template argument
i.e. struct B : A<B>
 
6:58 AM
this is the best sense I can make of it:
0
A: Virtual inheritance and static inheritance - mixing in C++

Fred NurkI'm not sure I understand what you're asking, but it appears it might be: template<class T> struct A { void func() { T& self = *static_cast<T*>(this); // CRTP self.func(); } }; struct V : A<V> { virtual void func() { std::cout << "V::func\n"; } }...

 
 
2 hours later…
9:22 AM
@tina ok (i'm not sure exactly what concepts you're referring to though) :-)
 
10:08 AM
@tina nice figure. this talk about boundary of point still just baffles me, though. i'd need to read up on things (and I think I will).
As I recall from the first time I checked this out there is an ISO standard. Or possibly some other international standard organization standard. That should be a definitive reference, laying down the law on these things.
If you have Word or Open Office, then there's nice drawing tool directly in Word, and somewhere in Open Office (I'm not very familiar with Open Office).
It's possible that the code you're analysing has bugs, but since this is very fundamental, used at the bottom of the system, any bug there should have shown up in all kinds of scenarios, so most likely this particular code is correct -- in spite of its ungrokkable nature.
 
11:03 AM
is there something like a generic tuple that exists in C++?
 
sbi
@Tony boost::tuple => std::tr1::tuple => std::tuple
 
auto x = std::make_tuple(42, std::string("yay!"), 3.14);
 
cool thx
is there a perf issue on storing maps inside maps?
like on copying, filling map A with 100 elements and the placing it in another map, would that be an ineffective thing to do?
 
11:30 AM
@Tony that's exactly the situation move semantics address; unless you know in advance that it will be a problem or you find out later that it is a problem, don't worry about it
 
@FredNurk, ok cool
I won't worry then
 
without move semantics, you could add the map to the other map, then fill it
or use poor man's move semantics: add an empty and swap with your filled map
e.g. template<class C, class T> void emplace_back(C& c, T& x) { c.push_back(T()); using std::swap; swap(c.back(), x); }
vector<int> v; int n = 42; emplace_back(v, n); is poor man's move semantics for 0x's v.emplace_back(42);
@Tony: 100 is tiny to be worrying about copying; 100,000 is more like it
 
oh ok
 
$ time python -c 'list([dict((x, x) for x in xrange(100)) for _ in xrange(1000)])'

real	0m0.106s
user	0m0.092s
sys	0m0.008s
that's the time required to copy 1,000 dicts (== C++ map) with 100 items each, and python is generally at least an order of magnitude faster in raw speed compared to c++
hmm, except I'm still only copying object references
$ time python -c 'list(dict(d) for d in [dict((x, x) for x in xrange(100)) for _ in xrange(1000)])'

real	0m0.122s
user	0m0.084s
sys	0m0.032s
that actually copies the dicts
 
@FredNurk so how come Python can be faster then C++? It's not closer to the hardware then C++
or has that nothing to do with it?
 
11:40 AM
I meant s/faster/slower/ (reworded it halfway through)
though, to be fair, list comprehensions / generator expressions are fairly well optimized
remember that you can't notice CPU-speed differences unless you're not doing slower operations like disk IO, network IO, and user interaction
 
so you meant Python is slower...
 
Uh, generally its meaningless to compare speeds of languages; it only makes sense for particular language implementations, on particular systems, with particular system loads and usage patterns. But. Python and C++ are at extreme ends of the scale, so it's about the same phenomenon that makes "entropy" a useful concept. Python is dead slow. Google stopped using it.
 
@alf: "implementations" was implied
do you have a reference for google?
 
@FredNurk Uh, google it? <g> They got Brian Kernighan (I think it was, one of old timers who did C/Unix at Bell Labs) to design new replacement language. But I think in practice they'll just be using other languages.
 
you mean Pike? designing Go? they still have mounds of python code and are still paying GvR to develop it
Rob Pike
 
11:48 AM
Yeah
 
last quote I heard is language choice is mainly determined by which dept./ecosystem you're in (e.g. what they currently use), rather than properties of the languages themselves
(which is how it works most places, most of the time)
 
yeah. problem with python though (with respect to efficiency, but python is very nice language in other respects) is its extreme dynamism. optimization cannot rely on anything (roughly).
 
but as I hinted above, that often doesn't matter :)
I consider it a flaw in the design, but it also dates back roughly 20 years
then again, it makes certain things possible that some people love, like zope.interfaces
 
12:05 PM
python is 20 years old? wow
 
12:26 PM
just barely :)
I'm not sure exactly why (though I know why I like it), but it seems to be particularly popular with c++ programmers
like the response to my comment at stackoverflow.com/questions/4220247/…
all I have to do is link to one of @FredOverflow 's questions to get him to join? have to try that again sometime
 
@FredNurk get me to join what?
 
12:43 PM
this room
 
@FredNurk i came here 20 minutes before you posted the link...
 
and I was talking to you... didn't even notice it, but did notice your avatar moving around the screen in the middle
probably a good sign I should get some sleep
 
@Johannes: What do I need to read in order to understand what liftM2 does?
 
1:01 PM
@FredOverflow long ago i tried to get into haskell and these things, but were unsuccessful
now i try again and it seems i'm more successful. yet i've forgotten what liftM2 does. some monadic stuff, iirc
@FredOverflow there is a manual for all haskell functions somewhere, i remember
 
potential FAQ item?
5
A: How to traverse a stl map?

John DiblingSure. This is the basic method: #include <cstdlib> #include <map> #include <string> using namespace std; int main() { typedef map<int,string> MyMap; MyMap my_map; // ... magic for( MyMap::const_iterator it = my_map.begin(); it != my_map.end(); ++it ) ...

 
a design question: I find myself doing the same thing in my code in many different places, but under different scenarios. Is this 'repeated code' a sign of bad design?
 
i say yes, but only because if you have 10 pieces of code that do the same thing, its difficult to maintin
 
so perhaps I should see if I can use another level of abstraction
 
@Tony: yes, unless you can't refactor it out due to a language restriction
 
1:14 PM
the thing I am doing over and over seems to be traversing XML docs in different ways to get the values.... for different purposes
 
the general way to approach that is to refactor each of the 10 uses to be literally identical; use local variables above the common code. then replace the common code with a function or class, with those local variables becoming parameters
 
sbi
@Tony The Programmer's All-Purpose Cure: Another Level of Indirection
 
@sbi haha
 
@Tony: trivial example: "c = a + b" and "z = x + y", where the second becomes "int a = x, b = y, &c = z; c = a + b", now you can write it as a function "c = add(a, b)" and the second becomes "z = add(x, y)"
 
sure
but I need to make a template function I think that traverses and XML node and allows me to do different things at different points, like with the Elements, the Attributes of the elements, not quite sure what the best way is
 
1:20 PM
maybe that's too obvious, but I want to stress literally identical; in simpler cases you can visualize it mentally, in more complex cases it really helps to do it literally
 
so I can dynamically insert functions to do what I want with the different parts of the tree
 
functors are how you inject behavior in c++
e.g. std::find_if
 
hmmm let me have a look at that
 
without 0x, functors can be a pain and that can qualify as a language restriction justifying the duplication. depends on the exact situation
 
i have boost, not 0x
so unless boost has them, I won't be able to use
 
1:23 PM
boost's lambdas make it easier, but still a huge pain in more complex cases
don't be afraid to see if a non-0x functor, which is just a function pointer or a simple short class (at namespace scope), would let you refactor and simplify
 
yea
 
1:35 PM
Hi there, can someone tell me what I'm missing here?
ImageSheet::ImageSheet(const string filename, const int tileSizeX, const int tileSizeY)
map.cc: In constructor ‘map::ImageSheet::ImageSheet(std::string, int, int)’:
map.cc:13: error: no matching function for call to ‘map::Image::Image()’
map.h:16: note: candidates are: map::Image::Image(std::string)
map.h:7: note:                 map::Image::Image(const map::Image&)
I don't get it...
Currently the constructor is empty
 
@Ivo: You sure the ctor declaration & definition are the same? You definition above has const int`s, but the error message says the ctor has non-`const ints
 
public:
    ImageSheet(const Image image, const int tileSizeX, const int tileSizeY);
    ImageSheet(const string filename, const int tileSizeX, const int tileSizeY);
It complains about a missing constructor for Image, but yet there is no call to Image in the ImageSheet constructor
 
@sbi: i faq-ified the link above. approve/disapprove?
you're passing an Image to ImageSheet by value
that will call the ctor
you sure you didnt want const reference?
by the way, i was going to ask you -- why pass parameters by const value?
 
@JohnDibling Uh, yeah... you're right that's stupid. Still it also complains on the constructor that takes the string :/
 
there might be some kind of implicit conversion or something going on
 
1:44 PM
@IvoWetzel: Image doesn't have a default ctor, and you're not specifying which ctor to use
Image must be either a base or a member of ImageSheet; looks like the latter
minimal example of the same error: codepad.org/UidDIHG6
 
Ah ok, so guess I need to do it via reference then, am I right?
 
passing an Image parameter isn't the problem (Image does have a copy ctor); notice the first ctor you mentioned (the string, int, int one) doesn't have an Image param
@JohnDibling top-level const is ignored for signature
 
@Fred: My point was that it's pointless
 
you asked if the declaration and definition are the same, I said top-level const doesn't affect that
void f(int); void f(int const) {/*defines f(int) that was previously declared*/}
 
sbi
@JohnDibling I dunno. I'm not the FAQ police. :) Was this asked before?
 
1:51 PM
Oh, that's what your referring to. I was thinking the signatures might be totally different. Like the decl took a ref and the defn took it by value. Typing error
@sbi: nope
 
the wrong signature would be a completely different compile error or a link error :)
 
ok it tries to call the constructor for the image member
 
@fred tru dat
 
@Ivo: use the ctor initializer to construct members
@Ivo: probably ImageSheet(const string filename, const int tileSizeX, const int tileSizeY) : image_data_member (filename), size_x (tileSizeX), ...
@Ivo: or you could change Image, or make that member a boost::optional (to be constructed/ignored/etc. later), and so on
 
@FredNurk Using const Image& image made it work
 
1:59 PM
using that where?
 
in the constructor definitions etc
 
I don't follow, but if it works, *shrug*
 
Dunno not tested yet need to grab a test image... basically I'm writing theoretical code right now, won't display anything, need to switch from SFML to SDL...
 
@John: you also need auto& val in addition to the string ref, as you're copying the pair<int const, string> out of the map: stackoverflow.com/questions/4207346/how-to-traverse-a-stl-map/…
the lambda version has a similar problem, if you're going for equivalence between the 3 methods
 
@FredNurk Well it works
Only problem SFML doesn't support my alpha channel PNGs -.- And I thought it was a good library
 
sbi
2:10 PM
@JohnDibling Well, anyway. If you consider something worthwhile, then that's fine with me by default. None of us has any experience with this. Let's just try what we think works, and weed out later.
 
@FredOverflow usually if you just play around and ask about liftM2 ppl in #haskell are all happy to help you xD
 
2:40 PM
so how many of you folks use IRC?
 
3:11 PM
@fred, @sbi, sorry I wasnt here :)\
 
sbi
@John Fine with me, because I'm leaving right now. :)
 
@sbi peace out
Did SO just burst in to flame? I can't load the site
The site seems totally hosed
well, it seems to have gotten better
 
3:50 PM
Hi everybody!
 
greetings & salutations
 
Not sure if this is the place to ask, but is there a way to catch a serial downvoter?
Someone has been downvoting almost every answer to stackoverflow.com/questions/4216639/…, except for one, apparently
 
@larsmans: I had this problem yesterday too. @sbi tells me that the system does an automagical check for this nightly. when he had this problem and posted on meta about it, they said "relax, we're already on it"
 
ah, thanks.
I don't mind about the -2 rep, but I don't want my solution to stand at -1
 
right. yesterday someone went through and -1'ed everything I had said that day. the rep didnt matter, but it bugged me
 
sbi
4:27 PM
@JohnDibling @larsmans Actually, they said the script is on it. I'm not sure what the chances are of them going to look after what the script doesn't catch.
@larsmans Oh, never mind that last statement. What I had been dealing with was someone being after me, spending all their votes on down-voting my answers left and right. I have no idea about down-voting all answers to one question. (But I have seen long-time users taking this without any indication of intention to flag it. So it seems unlikely that there's a remedy.)
 
@sbi, how do I flag such an offense? I haven't dug into this kind of admin work yet.
 
sbi
@larsmans There's a "flag" next to the one reading "edit", underneath your answer. You have a little edit pane to pass a Tweet-sized note to a moderator. But, as I said, I wouldn't hold my breath.
 
4:42 PM
lol this guy thinks iÄm a nitpicker: stackoverflow.com/questions/4222651/… xD
 
sbi
@Johannes Well, but are!
 
Do you guys think we should have a c++-faq "How do I turn my c++ code in to a program"? With a different answer for each compiler/environment? Or is there one already?
 
Erm... compile it? lol
 
What does compile mean?
 
4:57 PM
@PigBen It is german and stands for "come, understand!"
 
So I turn my code in to a program by "come, understand!"ing it?
 
(Did any of the german readers get it?)
I'm sorry, but if you don't even know what "compiling" means, why on earth are you using C++?
 
"compile" comes from "come and take this pill"
 
ppl left out the middle part over time and it became com-pile xD
yes sometimes i'm downvoting really stupid questions that just can'T be trolled
s,can'T,can only,
 
5:01 PM
@FredOverflow The word compile means to gather things together. How does that help a beginner who is just learning how to program?
 
lol
so a faq says "you then click the 'compile' button" and the guy wonders "where is the button!? my clothes are without them!"
 
I was thinking along the lines of each answer containing instructions of how to find and install the compiler, then how to use it on a simple program with a single source file.
 
btw what is the origin of the s/foo/bar/ search-and-replace syntax?
@JohannesSchaublitb lol @ button
@PigBen If it's well-written, I will certainly upvote
 
5:44 PM
@FredOverflow It's been around so long, used (with variations) in so many line editors, that I doubt anybody could actually pin down the first one to use it. I first encountered it in xedit on a Control Data mainframe, decades ago -- but it had also been in its predecessor (edit), going back to around the early- to mid-1960's. I doubt that was the first though -- just the first of which I was aware.
0
Q: When should I use the keyword "typename" when using templates

PacaneHi, I've been working lately on a small project, and I couldn't figure out something.. I've been given a .h file that was containing a class, using a typename template. Inside that class there was a private class. Header The problem occured when I wanted to define the functions of the class "...

Looks like a good candidate for a FAQ to me. Pretty decently written, links to problem code (that maybe should be moved into the question), etc.
 
I agree, but it needs a good answer
 
@JohnDibling It sure does -- and the ones it's getting so far don't really qualify, at least IMO. They're fair, but not great by any means. Unfortunately, I don't have time right now...
 
@Jerry: same & same
@Jerry: I nominate litb
:)
 
sbi
@JerryCoffin That would make a great FAQ. Anyone doing a good answer to this?
 
6:04 PM
not me, no time
 
6:18 PM
Do we honestly need a FAQ explaining how to compile one's code? :-/
 
unicode string is null terminating?
 
@James: I was wondering that myself
My inclination is no
and even if we did, wouldnt we steer that question towards programmers.?
 
@James: It is frequently asked, is it not?
 
6:33 PM
@PigBen: To my knowledge its not asked all that often. I could be wrong. And if it were asked, it would probably get closed pretty quick
 
@John: It was asked just 3 hours ago here: stackoverflow.com/questions/4226224/…
And I think it fits under 2 of the 4 categories of what kind of questions you should ask on SO. "software tools commonly used by programmers" and "matters that are unique to the programming profession"
 
I honestly don't believe this is frequently asked. I don't think many visitors to Stack Overflow are that clueless.
 
7:30 PM
Hi. Could someone take a look at why pastie.org/1311601 won't compile? (it's a templated name scope issue). g++ returns : 'expected constructor, destructor, or type conversion before ‘X’'
 
I get the feeling there needs to be typename instead of class there, just a guess
 
you missed a const
template<class K, class V>
class X
{
typedef unsigned size_type;
size_type count(const K& key) const;
};

template<class K, class V>
typename X<K, V>::size_type
typename X<K,V>::count(const K& key) const
{
}

int main() {}
 
hmmm, g++ 4.4.3 still complains

test2.cpp:8: error: expected unqualified-id before ‘const’
test2.cpp:8: error: expected ‘)’ before ‘const’
what am i missing?
 
one typename is wrong there. erase last typename.
i recommend reading "c++ templates, the complete guide"
 
@JohannesSchaublitb: Thanks! Both for the solution and for the reading recommendation.
 
7:44 PM
template<class K, class V>
class X
{
public:
typedef unsigned size_type;
size_type count(const K& key) const;
};

template<class K, class V>
typename X<K, V>::size_type
X<K,V>::count(const K& key) const
{
X::size_type ret = 1;
return ret;

}

int main()
{
X<int,int> my_x;
X<int,int>::size_type s = my_x.count(1);
}
you were also missing a return statement
 
 
2 hours later…
9:42 PM
no 'object' file generated what is this?
 
9:56 PM
in MSVC that means the compiler is grumpy with you
 
Would you like explain a litt
 
10:12 PM
Google "no 'object' file generated" (or in Visual Studio, select the error number and hit F1)
 
@Alex: are you using MSVC?
 
funnily, to english speakers that have no clue about c++, "no object file created" would seem to mean "ah everything is ok, no objections!".
 
@litb: ah, yes. except that I believe the words "error" or "warning" appear on the same line :)
 
Anyone know a good link that explains why "but it works on my machine" is not a good reason to ignore undefined behavior?
in 8 minutes, it will be beer-o-clock! wewt!
 
10:38 PM
it is beer:07, later all
 
10:48 PM
@JohnDibling yes, I move my code from normal make project, and use CMake to generate VS project, then this happen
 
sbi
11:22 PM
Wow, ow lively here!
@JohnDibling Maybe this might help:
25
A: ( POD )freeing memory : is delete[] equal to delete ?

sbiWhether this leads to a memory leak, wipes your hard disk, gets you pregnant, makes nasty Nasal Demons chasing you around your apartment, or lets everything work fine with no apparent problems, is undefined. It might be this way with one compiler, and change with another, change with a new compil...

?
Hullo?! <admires_hall> Well, it's bed time anyway...
 
11:40 PM
Hello
 

« first day (34 days earlier)      last day (4899 days later) »