« first day (545 days earlier)      last day (4616 days later) » 

sbi
sbi
6:00 PM
@rubenvb I don't know if that works or not.
Which animal is next?
@sbi hey, we don't have a polar bear in here...
@daknok_t lol
Does the Dragon Book explain lexing?
6:02 PM
It explains everything.
@RMartinhoFernandes Nervous giggle at that:
7 hours ago, by R. Martinho Fernandes
TF? That user<prime-number> that most of us have ignored just went into the JavaScript room to spam with links to his C++ questions.
sbi
sbi
@EtiennedeMartel ...that was known at the time. But, yeah, compiler theory hasn't added much since.
@EtiennedeMartel Then I'll look if I can find a copy. It's a very good book people say.
No, it can't?! Can he? I bet he wasn't trolling. Just asking serious questions, I bet
sbi
sbi
Should I ever get bored of the grumpy gorilla, this grumpy otter would do, too:
6:04 PM
@EtiennedeMartel Ah, you're in synch with your true self now
@sehe Has he got the Great Hammer of Justice in the kneecaps?
@sehe Fucking A'.
@EtiennedeMartel I believe he's banned now, if I read the further chat messages right
Good. All is right in the world after all.
sbi
sbi
2 hours ago, by R. Martinho Fernandes
> This user has been temporarily suspended by a moderator and cannot chat for 6 days. that user-prime-number-guy
@EtiennedeMartel I think he got it into the back of his head.
Brillant
6:06 PM
That'll teach him.
sbi
sbi
@EtiennedeMartel Don't get overexcited. There's still wars and things.
@EtiennedeMartel No it won't
Hey, I just woke up.
sbi
sbi
@EtiennedeMartel Not quite yet, it seems.
brb, I'm getting a copy of the Dragon Book.
6:07 PM
Oh, you.
Xeo
Xeo
0
A: Why should one use std::string over c-style strings in C++?

asanokiIn general you should always use std::string, since it is less bug prone. Be aware, that memory overhead of std::string is significant. Recently I've performed some experiments about std::string overhead. In general it is about 48 bytes! The article is here: http://jovislab.com/blog/?p=76.

I'm calling MSVC in debug mode.
Yeah, looks like it.
@Xeo Oh, @MooingDuck has a nice comment on the blog article that guy linked.
back
Xeo
Xeo
Yeah, my message was basically an answer to that
Well, I'm going to read a book. See you later guys!
6:20 PM
@Xeo " As for the opening, I think that std::string is not faster than char-array with C functions such as: strcat, strdup, etc."
Xeo
Xeo
I was just about to write a reply to that
Since std::string by default uses exactly those
through the char-traits
Do you want to write one instead?
I've never run into a situation where the performance of string operations was a bottleneck...
Xeo
Xeo
@Mooing, you can hit the small "reply" text at the bottom of his comment
@Xeo too late now
Xeo
Xeo
Yeah, but for the next one :)
6:28 PM
Could someone tell me how to cast a char into a string?
char c = 'A'; std::string s = c;
sbi
sbi
So I have this setup with half a dozen processes collaborating. I attach to one while it's initializing, and a global object (this is C# and not my code) retrieves some int value from another process and stores it in a data field. Later, yet another process invokes a member function on that global object, and then the value of that variable is wiped out. WTF? I've been trying for hours to hunt this one down.
@GManNickG Does std::string have a ctor taking a char? Not in C++03, I think.
@sbi It does have a constructor that takes both a char and an integer, I think.
sbi
sbi
@EtiennedeMartel Yep, that I know. So it would have to be std::string s(1,c);, @unNaturhal.
6:37 PM
Yeah, seems about right.
@sbi No it doesn't, I meant to do s; s = c;.
sbi
sbi
@GManNickG It has an assignment operator taking a char? I didn't know that.
@sbi: Yeah, it's a bit silly if you ask me, to have op=(char) but not const(char).
sbi
sbi
Damn, it seems VS can't set data breakpoints in .NET.
Try to say in other words :P
How I can obtain this:

char c;
string tag = tag + c;
?
sbi
sbi
6:41 PM
@unNaturhal string tag = tag + c; attempts to add something to a not yet initialized string.
That makes no sense.
Of course tag is initialized, as well as c. I uses this way just to show how I would obtain
@sbi If the object lives in shared process memory, you could be overwriting it in another process?
@unNaturhal: char c = 'A'; std::string tag; tag.push_back(c);
if you're desperate
allocate int on it's own separate page and only offer accessors
and set the page to be non-writable
Hi. I just have a design question I'd like to here a few opinions about. So, given you have a server class. This class basically needs a method which starts an endless loop. Would you implement that directly into the constructor, or would you put it in a run() method or something? Same question for a client class.
6:44 PM
then catch the access violation if anyone tries to write to it
@GManNickG :D Yeah, right this! :D
Note that if you're concatenating lots of strings and characters and whatnot into a single buffer, you may want to use std::stringstream.
sbi
sbi
@DeadMG No shared memory involved. Communication is all via some .NET voodoo.
so a message passing style voodoo then?
sbi
sbi
@DeadMG Haha! I'm in C#/.NET, and there's hundreds of layers between my code and the metal!
6:47 PM
@cooky451 put it in a run function, otherwise if an exception is thrown, it's destructor wouldn't be run.
P/Invoke the WinAPI can cut through all of those layers at once
but I find it strange that you're having such a problem in .NET- the kind of thing that can cause this in C++ should be prevented by the CLR
so I think I smell a concurrency heisenbug
@GManNickG It's perfect this way, thanks :)
sbi
sbi
@unNaturhal No, it's not. string tag defines an object and calls its constructor. While that is called, there is no tag object yet. Either you mean string foo = bar + c; or string foo = c;.
@DeadMG Well, my latest analyzes turns out the value is that of a newly constructed object. Only the object has the same ID in the debugger as the old one, none of my breakpoints in the ctor fires, and the other values are fine. This must be something stupidly silly, and I am just too deep into that shit now to realize the obvious. I guess I should call it a day week, go home, and check on it on Monday.
yes, I think that would be a smart move.
@unNaturhal: In general, T x = y is equivalent to T x(T(y));, so when you write std::string tag = tag + c, that's the same as std::string tag(std::string(tag + c)). Note that in calling the constructor for the temporary string, you read tag...which isn't yet constructed, leading to UB. Basically, it's dumb that objects can be used before they are constructed but that's how it is.
6:51 PM
mawning
@GManNickG I don't think it's dumb. You can, for example, pass it to a function which just stores a pointer/reference to it, which is fine
@DeadMG: You can probably do that anyway even if the name isn't in scope until after the initializer, just have to use two lines instead of one: T x = track(x); => T x; track(x);.
unless you need the return value of track(x) to construct x.
Plus it would solve the rare shadowing issue that doesn't matter but it solves it anyway: int i = 0; { int i = i /* ?! */; }.
@DeadMG Sounds like bad design to me, though without being more concrete who knows?
eh
consider constructing in an initializer list, for example
class Y { T* ptr; }; class T { Y y; };
6:56 PM
Probably want that to be struct yes? (Or public, rather.)
whatever, you get the point
Okie, go on.
(I will afk for a little bit though, but I'll be back.)
> "Never attribute to malice that which is readily explained by stupidity"
oh that's a nice piece of advice :)
7:11 PM
@rubenvb Fixed that for you. Refresh your browser caches !
@sbi thx for a good nudge + nice animal
Certainly less boring than the hashcode mandala
oh a polar bear
nice to meet you Mr. Polar Bear
this place is getting more and more exotic as time goes on
:P
sbi
sbi
@sehe Hehe, indeed a nice one!
And you're even keeping with the animal theme of the room!
And with paw-covers-eye meme, which fits my non-visual-mindedness quite nicely
lol
Who'd have thought that a puppy, a gorilla, a Lion and a polar bear would ever come to chat with each other peacefully?
@DeadMG :(?
7:26 PM
@TonyTheLion who'd have thought animals would chat?
sbi
sbi
About C++!
Well, I gonna go home. It's unlikely that I should log back in tonight, and with the weather announced I'll probably spend most of the weekend digging through my garden. Have a nice weekend everybody!
@sbi Cheers, and watch your back! (as in - prevent injury)
Am I the only human left?
@EtiennedeMartel call it human, if you want. You look like a cartoon to me
But my paw might be obstructing my view
It's a cartoon representation of me. Or at least it used to be, because now I have a beard.
7:32 PM
@GManNickG huh?
I should update this. Eventually.
multiline messages
appear to grow your avatar
ursus minor
to ursus major
(yep, worked)
@KonradR woot, someone spotted a limitation in that other expression grammar of mine:
@SergejAndrejev nice observation. I fixed it by providing right recursion for the binary operators (and_, or_, xor_) and added your testcase. Thanks for the heads up — sehe 6 mins ago
@Xeo I posted a reply with a test case/compiler that shows that std::string took 41% less memory than char*. We'll have to see how he responds to that
> -- Warning: I’m an idiot and I’m learning Haskell , code may suck -- GManNickG
@GManNickG trying to work out whether that is tautology, pleonasm, paradox or contradictio in terminis
7:59 PM
@CatPlusPlus white, plush animals rule, don't ya think?
@sehe SEHE HAS A PICTURE! O.O
6
@MooingDuck Yup I do. I succumbed to peer pressue
Masif heap profiling on 64 bit: http://pastebin.com/CammDHvj
That's with
    std::unique_ptr<std::string[]> ctest(new std::string[LEN]);
    for(int i=0; i<LEN; ++i)
        ctest[i].resize(stringlengths[i]);
    std::cout << "virtual memory after: ";
@sehe masif sounds interesting, what is it?
@MooingDuck valgrind heap profiling tool.
@sehe Yes.
8:04 PM
@sehe neat
@sehe how does that compare to the char* version?
sudo apt-get install valgrind
time valgrind --tool=massif ./test
ms_print massif.out.* | xclip -i -selection clipboard
@MooingDuck lemme try
49.99% (15,499,235B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->25.80% (8,000,000B) 0x40093E: main (test.cpp:23)
That's the peak, but of course with a different total size. Let me see whether I can use a massif header to trigger snapshots at the right moments
I just find it interesting that GCC's string uses that much more memory than MSVCs' for small strings.
GCC uses refcounting for strings.
And no SSO.
@CatPlusPlus oh, right. I thought that was disallowed now?
it's also interesting that VC allocated almost twice as much virtual memory than GCC for the char*, that might be related as well.
8:18 PM
With all three in a row, on my 64 bit gcc 4.6.1 -O3 this happens:
{
    std::unique_ptr<char*[]> ctest(new char*[LEN]);
    for(int i=0; i<LEN; ++i) ctest[i] = new char[lengths[i]];
    for(int i=0; i<LEN; ++i) delete [] ctest[i];
}
{
    std::unique_ptr<std::unique_ptr<char[]>[]> ctest(new std::unique_ptr<char[]>[LEN]);
    for(int i=0; i<LEN; ++i) ctest[i].reset(new char[lengths[i]]);
}
{
    std::unique_ptr<std::string[]> ctest(new std::string[LEN]);
    for(int i=0; i<LEN; ++i) ctest[i].resize(lengths[i]);
}
--------------------------------------------------------------------------------
Command:            ./test
Massif arguments:   (none)
ms_print arguments: massif.out.10495
--------------------------------------------------------------------------------


    MB
51.02^                                                                ##
     |                                                               :#
     |                                                              ::#
     |                                                            :@::#
um................
0
Q: whole program optimization + o2 = broken MSVC

acidzombie24I am using MSVC11 beta. When i have both whole program optimization and o2 on my app will crash. I have no idea what is wrong. The only warning i have is the below and unused variable. Gcc wall gives me NO warnings. Gcc runs in release mode just fine. How do i figure out what the problem is? I ...

I'm gonna show up two days after yesterday!
8:40 PM
really? I'd never have guessed
I don't get that guy. He's been posting newbie questions for something like 5 years
on gamedev.net before SO
@jalf who?
good, so I wasn't the only one who thought it was unusual to see a high rep user post a bad question...
on the other hand, I have to admire his persistence and willingness to post seemingly simple questions
Oh my, 1359 questions.
8:45 PM
oh my
I don't even have that many answers...
wth? New answer on an old question...
0
A: Fastest programming language for computing large numbers?

annoying_squidHere is your resource to read up on. This refutes the argument that C is fastest, unless you use the C99 restrict feature. If anything C++ is faster than C. It really comes down to the compiler understanding when two separate but sequential operations 'read' reference the same memory location....

I fail to see how that's relevant to the question.
how much rep is required to comment vs answer?
Damned C++ and its strings!
You have never seen C.
Why do people believe that you can't debug a release build I never understand.

« first day (545 days earlier)      last day (4616 days later) »