« first day (481 days earlier)      last day (4475 days later) » 

user868935
6:02 AM
@LucDanton I'm not storing integers. I'm trying to use numbers to call a specific string in a string array. So if cin >> input;, and the user types "0," when I call var1[], it will act like I was calling var1[0].
 
Xeo
@Paul Then call setVar(std::string var) with setVar(var1[input])
 
posted on February 09, 2012

Optimization is not always a synonym for "making a program run faster."

 
Xeo
5 year steps sounds good, especially with TRs
 
sbi
Damn, what did I do wrong there?
 
Xeo
6:16 AM
space
after (yay!)
 
sbi
Meh.
 
Xeo
Hm.. any way to get an RSS feed from Twitter?
 
sbi
@Xeo I dunno. What for?
 
Xeo
sdt's tweets. Kinda relevant in here, and a good choice for the minibox in the corner
 
sbi
@Xeo I wouldn't do this. Twitter users are notorious for posting lots of irrelevant and private stuff. Just because he's posting lots of C++-related stuff right now doesn't mean he will do this all the time. Also, he's maintaining quite some volume, currently, producing a dozen tweets at a time in short succession. That would be very disruptive.
 
Xeo
6:22 AM
@sbi Would be nice if it was filterable
 
sbi
@Xeo Such filtering would have to be done by human beings. And that we already have.
 
Xeo
:P
 
sbi
Well, maybe this would be worth monitoring. But it's still short bursts of very high volume, which IMO is unsuitable for being pasted here automagically.
 
Xeo
Hm, I somehow want to write proposal for tuple-for (for(auto& e : a_tuple)), but I have no idea how to write one.
 
sbi
@Xeo If you want to do this, I suggest you, 1) post the idea in comp.lang.c++.moderated, 2) make it a boost lib, 3) find someone among the committee folks who likes it and would help you to push that through.
 
Xeo
6:34 AM
@sbi Can't be done as a lib without inconveniencing the user a good bit
Atleast I didn't find a way when I did a pure library based reference implementation that allows control structures (break, continue, return)
And even then the return case is tricky
But thanks for the advice
 
sbi
@Xeo A core language proposal will be much harder to get through than a lib. And it reduces your chances to get allies to #3.
 
Xeo
I feared that. :/
 
sbi
Anyway, I gotta do things now.
afk
 
user868935
7:22 AM
I'm having problems opening a text file to read each line...
 
8:48 AM
Anyone out there? Need a little help.
 
just ask
 
ask
 
Is there a way I can obtain an integer representation of a string that would uniquely identify that string?
 
@Xeo hmm, that'd be nice
 
Like if "hey" -> 150, then in another instance "hey" should be mapped to exactly 150
 
8:53 AM
but if you have another "hey" at a different memory location, should it also be mapped to 150?
 
Or is that a stupid question? :S
 
you need big integers for it
 
@kfmfe04 yes
 
you can do a lot if you know your data better
 
@Abyx can you give me a code snippet, please?
mm?
 
8:53 AM
no.
 
@thameera then you are talking about a hash function for strings - one that does not collide
@thameera - you can look at crypto libraries for that
 
if its simple enough why not a map
 
because in a typical map, you will get collisions
 
I tried a map. Had some problems with it :S
 
it depends on what you are trying to do with it, thameera - perhaps your requirements are too stringent
 
8:56 AM
yes. based on your requirements I am sure you might get some ready made hash functions on the net
 
@thameera note that std::map is a red-black tree that doesn't use a hash function
 
char* zname = "tham";
mapA[zname] = someObject;

Now the command "cout << mapA[zname];" gives someObject,
but "cout << mapA["tham"];" returns 0
:S
 
don't use char* - use std::string
2
and you will be fine
 
mapA is declared as
map<char*, class*>
aah, is it?
the problem is the input I'm receiving is a char* :(
 
@thameera one is a pointer, and behaves like a pointer. The other is a string class, and behaves as a string class
 
8:58 AM
std::map< std::string, YourClass* >
 
Perhaps I should convert that to string?
 
@thameera perhaps that would be a good idea, yes. :)
 
well,
even if we later try:
char* zname2 = "tham";
even then, mapA[zname2] would turn out to be 0
 
@Xeo Yahoo pipes sounds like it would do this
 
is this a problem with char pointers?
 
9:00 AM
@thameera No, they are perfectly well-behaved pointers
But there is a problem with expecting them to behave like strings
 
@jalf Any idea about the reason for the problem in my last code snippet?
@jalf It doesn't use strings
 
mapA is taking key as char * .. but when you do mapA["tham"] , you are giving key as const char *
 
@ArunMu
even if we later try:
char* zname2 = "tham";
even then, mapA[zname2] would turn out to be 0
 
the problem is your understanding of what std::map actually does - in the case of char*, the algorithm is comparing character pointers. In the case of std::string, it is comparing the std::string type vs another std::string type
 
does any one know if it is possible to send a command via filezilla to a remote server. I need to run a command to mount files...
else I can't ftp them...
 
9:02 AM
@thameera you are getting 0 because they are at different memory locations
 
wait... I can just move them to ~ via ssh :P
 
@kfmfe04 Ah I see, so how would I get rid of this problem? :S
 
@thameera you use std::string instead of char*
@thameera your only other option is to pass in a char* comparison operator yourself
 
@kfmfe04 Ah okay, I'll give it a try. Thanks a lot. :)
@kfmfe04 Perhaps converting the char* to a std::string will be easier?
 
@thameera much easier for a beginner
 
9:05 AM
@kfmfe04 Okay, thanks
 
Hi, anyone here uses GIT?
 
I do - but have so only for a couple months
 
@kfmfe04 It worked! Much appreciated :)
 
@thameera great - glad it worked out for you
 
enough @kf
 
9:09 AM
@JohnShepard I've given it ago, but didn't get on with it
 
i just started too :)
my question is, how do you sync htdocs with the git repo?
 
...but I am 100% certain that git is better than svn
 
i have searched in stackO and googled it
but i don't find anything
how do you work with it?
@thecoshman what do you use now?
 
what I do is create a separate depot for my htdocs
git can't tell the difference - they're just a bunch of files
 
but if you do that you can't access the separate depot with the git console right?
 
9:11 AM
I'm assuming that what you mean by htdocs is what is being served by a webserver out of a location like /var/www/ ....
 
htdocs as in a local server
C:/xampp/htdocs
 
well, on a *nix system, you can pull it into a working directly elsewhere and create a symbolic soft link to it (if you don't want to expose your .git directory)
 
i am working on win 7
:(
 
if your webserver will follow links, you can use the same technique
 
mmm
ok
 
9:16 AM
@JohnShepard subversion
 
win 7 can do sym links now as well
@john so you are trying to use git to back up a web site that you have on your win7 pc?
or host a web site from a git repo on your win7 machine
 
I would like to be able to have my website on htdocs
while still being able to use git
I was thinking maybe linking my htdocs/mywebsite with users/myname/mywebsite
 
well, probably the best way is to use git (or any other source control) to store your website locally, say in ~/myGitSite and then have a sym-link point from your website hosting directory to the local copy of your repo'
 
does sym-link update automatically?
 
9:25 AM
How can I get rid of the runtime error in this code? ideone.com/e65Wh
Is this because lst isn't instantiated?
 
@JohnShepard yeah, if I do a sym-link (not the proper name btw) to ~/my/sub/dir/ and place it in c:/ and call the sym-link shortcut then c:/shortcut is functionally the same as ~/my/sub/dir/ so what ever I add to the one is added to the other, but with only one copy of the contents
one thing to keep in mind though, if what happens if you do cd c:/shortcut ; cd ..
you can have that either take you back to c: or to ~/my/sub
 
@thameera no, it's because you're creating a pointer, and then pretending it points to something
 
I think one is soft link ad one is hard link
 
@Luc oh, sorry, been offline while I set up my new disk. Looks sweet.
 
@theco
 
9:33 AM
MyClass *oMyClass; declares an uninitialized pointer. It doesn't point to anything. And oMyClass->lst is asking for "the lst member of whatever object `oMyClass´ points to
 
Here they strongly recommend to avoid symlinks stackoverflow.com/questions/5917249/git-symlinks-in-windows
 
Pointers: just say no
you don't need a single pointer in that code
 
@JohnShepard from a quick look at this, it is on about having a symlink in your repo pointing to out side of your repo
 
But things need to point!
 
@jalf But this is a part of a long program. I need a pointer here. :S
 
9:35 AM
so a symlink of the whole repo would be fine? @theco
 
afaik most source controls, including the likes of dropbox, see the link like a windows shortcut, so they just back up that, they do not copy the sub folders of what the symlink points
symlinks that point INTO a repo' are ok
 
@thameera you very likely don't. And if you do, then you're going to have to step away from the compiler and buy a good C++ textbook before you do anything else
 
ok thanks a lot @theco
:)
 
@jalf Uh. I'll give another try perhaps. :S
@jalf Thanks
 
in the specific code you posted, MyClass *oMyClass; should be MyClass oMyClass;. Then you have your actual object instead of a pointer to nothing.
but of course, that depends on what you do with the object afterwards, if this is only a small snippet of the complete code
 
9:45 AM
@jalf Ah got it, thanks :)
 
10:01 AM
You gotta love the speed at which MS fixes their locking bugs in VStudio :)
3
A: Visual Studio "Find in Files" does not work

seheI think I recognize this wellknown, longstanding bug: http://connect.microsoft.com/VisualStudio/feedback/details/105511/find-in-files-says-no-files-were-found-to-look-in-find-was-stopped The workaround mentioned there worked for me when I had this problem I found a tip to try pressing Ct...

I know this from VS2003, VS2005, VS2008 and apparently now still in VS2010
+1 for consistent build quality though
 
@sehe What are you whining about? It only takes them a week or two to mark it as WONTFIX
5
 
> Microsoft Visual Studio 2010, Version 10.0.30319.1 RTMRel. This error is still happening in November 2011 when it was reported 7/20/2004. Remind me again how much Visual Studio costs? LAME.
lol
 
Ctrl+ScrollLock? Awesome.
 
@jalf awesome. You got the job as PR spokesman
 
mawning
 
10:04 AM
@RMartinhoFernandes Actually I suppose I quoted a strange case of someone that has scollock combined with the break key there. I'll edit for clarity
 
so pointers are supposed to be a powerful mechanism, but from my understanding, they should be used as little as possible. Is that because they are error prone? What is the gripe with pointers?
 
They suck.
 
@TonyTheLion Atoms are a powerful mechanism too
 
but that's not a technical reason not to use them
lol
 
Excuse me, but "suckage" is a pretty technical concept.
 
10:06 AM
:P
 
@TonyTheLion points are fine, it's the humans who are error prone
 
the technical reason reason is simplicity. In general, always choose the simplest, safest mechanism that'll work for you
 
rocket scientists generally rely on newtonian physics, not Einstein's relativity theory, because it's good enough for them, and it's a hell of a lot simpler.
And C++ programmers generally rely as little as possible on pointers, because for most purposes, you don't need what they can do, and they complicate matters
 
@RMartinhoFernandes noooooo :P
@jalf that makes sense
 
10:11 AM
you want to have as few moving parts as possible, basically
the less you have to think about, the better
 
right
 
and with a pointer, you have to consider that it might point to any of a billion different addresses (assuming it points to a 4-byte object on a 32-bit system)
 
right, and there's no way to be sure either it points to what you want it to point to, I mean you can't verify it
oh and pointer aliasing
 
also, honestly, the so-called "power" of pointers is overrated
the only "special" thing about them is that they allow pointer arithmetics within an array. Just like all other iterators do.
 
right
but they're the only way to get access to memory on the free store, no?
well, you have higher level abstractions, like unique_ptrnow, but under the cover it's still a pointer
 
10:28 AM
@TonyTheLion well, a reference can do that too.
and smart pointers, of course. It doesn't matter what's "under the cover". Under the covers, function calls are basically just gotos. That doesn't mean we should use gotos all over the place
what matters is the abstraction presented to the programmer
anyway, a reference can point to memory on the free store too. It just can't be reseated
 
it's all because of UB. But if compiler defines pointer behavior, you can write cool things like *(DWORD*)0xABCDEF = 42;
 
Hello people ! How is everyone doing ? :)
 
Hye martinho :) Long time ! how come there is no raging debate going on ? :)
 
10:43 AM
We're on break.
 
Bye any chance does any one use clearcase?
the archaic source control system
 
I used it :'(
 
am I retarded, or is it the most painful system ever?
 
I'd recommend to use mercurial, and synchronize with CC via clearfsimport
 
@Xeo Yes, definitely. Still waiting for D to take over the world.
 
10:51 AM
you are not retarded
 
sadly, this is for work, so if I want to stop using it, I have to stop working
and some how... I don't think they will pay me to not work
 
quit that work.
(so I did ;))
 
@thecoshman Like @Abys said, cheat: use some other VCS yourself, and sync back and forth.
 
I do like the fact that AFAIk it is the only source control that gives you access to stuff via a network drive rather then a local copy
@Abyx can you give me some pointers on doing this?
 
it's just a big DropBox
 
10:54 AM
Or, call your headhunter!
 
@thecoshman clearfsimport --help , it's really simple thing
 
@Abyx so... install n MG client, and then I can use this command to pull in all the vobs I need. Will I be able to perform all the normal snafoo, branching, 'config specs' etc. that CC uses?
 
it just will automatize all work you need to push your local copy to CC - check-in\check-out files, create directories and so on
so, you need to mount VOB with proper configspec, copy files form VOB to hard drive, edit'em, then use clearfsimport to sync them with VOB
 
so I need to set up MG repor for each VOB that I need to use...
and what about jumping between different config specs, something I currently need to do a lot
 
@thecoshman you can create one view per configspec
 
11:04 AM
@Abyx so I would make a new view for each config spec I want to work with, and then have a MG repo for each view of each vob?
 
dunno. what is MG ?
 
@Abyx mecurial :P
 
It's Hg, not MG.
 
oh
 
Oh yeah
lol, I feel just a bit retarded now :D
 
11:07 AM
well, if that repos have same files, why not to use branches (in hg)
 
you mean, use a Hg branch for different views of a vob... and each view is for a different config spec
 
yep.
 
so if I have 3 vobs, an three config specs, I would have three Hg repos each with three main branches, one for each config spec
here goes then :S this could all go horribly wrong :D
 
as I remember, you can have multiple VOBs in one view
but you'll need to join configspecs, somehow
 
Blue is a popular color for programming language logos
 
11:11 AM
currently, I have my main view, and I have about 10 vobs in it, and I have to swap config specs when I switch between working on new stuff and when doing bug fixing on older releases
 
ah, it's so good that I almost forgot that scary clearcase stuff =)
 
oh sh...
10 vobs ?
 
any way... need to restart chrome
@Abyx that's just what I need ¬_¬
I work in a rather large project :P
 
we used one big VOB for a hundreds of projects, and it worked somehow
 
11:14 AM
@Abyx each component gets it own vob, there are fuck loads
now to find out how to set up views again :P
fuck me it's a lot of arseing around to set up a view
@Abyx with clear case... each view mounts to it's own drive, with many vobs in this drive. How can I then set up Hg so that each Vobs is in a Hg Repo, but a branch for each configspec/view
 
11:35 AM
@thecoshman you can't "setup it", you can write scripts which will pull\push from VOBs to Hg repos
 
@Abyx but is it possible fog each branch of a Hg repo to be mapped to different views so that each branch is a different config spec?
 
you can map them manually
clearfsimport just do "copy" from one "directory" to another "directory"
create a script which will know which CC view matches current Hg branch
 
ergh... having to learn how to use Hg as well :P
so I 'clone' the first vob, which is a in a view (with other vobs) on the sonfig spec I want to start with...
 
11:52 AM
that seems to be fairly good guide to doing this, but I think I am going to have leave it for now, need to sort shit out
 
@thecoshman I used something like that script, but I wrote GUI application in C# for it.
 
oooh nice
I've taken to using AutoHotkey, so might look into using the GUI stuff of that
but thanks for the help bud :D
 
...and I deleted source code, because I believe I'll never use clearcase again
 
@Abyx lol
can't blame you :D
well that was just a little bit scary
all code just gone from repo
strangly, reset configspec, fixed
 
12:10 PM
> i never hug a girl. / this makes me / cry sometime...
not quite a haiku - yet
anyways marked that flag on 'what makes you attempt suicide' invalid :) Makes you wonder who flagged it. It there a flagbot based on a wordlist?
 
WTF is going on?
 
@RMartinhoFernandes that's a very broad question
 
12:55 PM
@RMartinhoFernandes with regards to what?
 
In case you are bored:
0
Q: Using strong typedef as a more lightweight alternative to Boost Parameter library?

StackedCrookedI often use the Boost strong typedef utility to improve the safety of my programs. For example by writing code like this: BOOST_STRONG_TYPEDEF(int, X) BOOST_STRONG_TYPEDEF(int, Y) BOOST_STRONG_TYPEDEF(int, Width) BOOST_STRONG_TYPEDEF(int, Height) struct Rect { Rect(X x, Y y, Width w, Height...

 
sigh... is it wrong to want to move companies because you just can't stand the development system !_!
 
@StackedCrooked For that specific example I'd prefer struct dimensions { int width, height; }.
 
@RMartinhoFernandes Indeed.
 
@StackedCrooked That's precisely one of the use cases of such a feature.
 
1:03 PM
But I've used something similar to that before.
I didn't use Boot strong typedef, but I used simple one-member aggregates.
 
@RMartinhoFernandes An example from my code looks like this: Player CreatePlayer(const TeamName & inTeamName, const PlayerName & inPlayerName);
 
Maybe one such utility could be template<typename Tag, typename T> struct wrapper;
 
@RMartinhoFernandes How does that work?
 
Just struct width { int value; };. Then I invoke functions with width { 800 }.
(I didn't know of boost strong typedef back then.)
 
see my comment on question
 
1:09 PM
fuck it =\ my code makes me mad. Why os << '\'' << buff << '\''; doesn't write last ' in stream =(
and I can't reproduce it without whole project %)
 
@RMartinhoFernandes That's clever.
 
I was reading some starting items of Effecting STL (re-reading in some way)(Had read effective C++ long time ago) and I realize Mr.Scott uses too much theory which is really hard to endure for me now, so can anyone point some very important items of that book only ?
 
@MrAnubis too much theory?
What kind of theory do you mean?
 
@jalf Items got too much text is I meant
 
@MrAnubis skip every other word then
 
1:16 PM
I don't understand how a book can have too much text. Did you expect pictures?
3
 
@jalf That won't work for me
 
You can't learn from a book without reading the book
@MrAnubis then become a plumber or hairdresser. A programmer who can't read is pretty useless
 
@jalf :(
 
If the problem is simply "too many words", then you'll just have to work on your reading skills. If the problem is "I don't understand what he's talking about", then the answer might be to read it again, slowly, looking up the parts you understand, or it might be to read some other books first, or to get more experience with programming or something else
 
> The world ephemeral as piss upon piss flaps
I never knew there was that much to be said about piss flaps
 
1:25 PM
Funny, I can seem to reproduce type-aliasing warnings anymore. On my machine I'm compiling with: g++ -o test -O2 -fstrict-aliasing -Wstrict-aliasing=2 -Wall -Wextra -Werror main.cpp . (It's g++ 4.2.1)
Ah apparently it was a warning that was generated on GCC 4.4.
Actually no.
 
1:40 PM
Is Boost Asio overkill for stream based fd?
 
File descriptor?
 
Yeah, file descriptors. I just need to pipe lots of stuff
 
Just saw a channel9 video with Herb Sutter on Why C++ & some C++11 ... have this sudden urge to just learn C++ better
Will pursuing windows apps in MFC be a good way to get better at C++? Or maybe QT?
 
@gideon Definitely not MFC. Qt isn't very elegant from the modern C++ viewpoint either.
 
1:50 PM
thats the thing, I mean If I wanted to write a useful C++ program there aren't many places to go
(I'm talking on windows here)
or maybe web, I think that could be painful though, I did check out some C++ web frameworks.
 
I have no problem using Qt. But I don't think it's a good way to learn more about C++.
 
hm. What would you recommend?
 
I would work through a good C++ book, like Accelerated C++.
And follow it up with Effective C++.
 
I have gone through that book (helped make me a better person too!)
aha
Effective C++ gotcha..
What do I do for practice?
 
Something that is fun enough to keep you motivated.
 
1:53 PM
Like making useful stuff in C++, I just learned C++ because I felt I needed to know it, I picked it up and could write decent console programs (some basic windows stuff) but I have no proper hardcore practise
I mean like if I have to make a windows program I would have to learn MFC, are there any alternative ways to use C++ to practice and make useful stuff.
maybe use the android NDK?
 
Why so determined to do applications?
 
I never really used MFC because it requires the paid version of Visual Studio.
I wrote on top of the old fashioned WinAPI.
However, these days I would go for Qt.
 
@StackedCrooked yikes! scary! (pure Win32API!)
@Pubby how else would I have experience, at work I do C#/.NET web apps.?
 
@gideon Yeah, I even attempted this.
 
ah looks cool!
@Pubby In the future if I apply for bigger CO's they want C++ how would I show I know C++?
 

« first day (481 days earlier)      last day (4475 days later) »