« first day (198 days earlier)      last day (4733 days later) » 
00:00 - 12:0012:00 - 00:00

12:00 AM
I doubt anybody ever presented a paper even suggesting it. Even if such a paper had been written, I suspect it would be dismissed with little discussion unless it was written by some fairly "high-powered", well-recognized people (in fact, if it didn't have at least one committee member as an author, writing it would probably be almost a waste of time).
 
sorry for this question, since i am quite a c++ noob, implicit conversaion is for me like short a = 200; int b = a; - this is a nice benefit for me (in my current way of thinking about it ), since i dont have to write some extra (int). oc, having time for writing this statement leads to having time to write these 5 extra characters, but why should i want to have it to be forced ?
 
The C++ committee is much more interested in suggestions that support new types of programming and add capabilities, not ones that work toward limiting the language to a few people's ideas of what would force people to write better code.
@dhanke The reality is that you probably don't. He was talking only about user defined types, but even there, use is common. Just for example, the standard advice to overload most operators as globals instead of member functions is specifically to support implicit conversion of the left operand.
 
i see
 
@JerryCoffin sure, I'm considering "is there a reason to deprecate it" in an ideal world, rather than with extraneous practical considerations
@JerryCoffin but the motivation is not constraining others, it's consistency and making my world better
e.g. "every ctor is explicit unless explicitly made implicit" rather than having to 1) count parameters and 2) check which are defaulted
 
regarding my "benefit", i noticed that php seems to implicit converse any-to-any, which can lead to really bad results. - this just as an addition to my prior question
 
12:07 AM
and 3) try to remember, 3 months later, if I forgot to add "explicit" or intended the implicity
@dhanke php does nearly nothing correctly, so just because you can burn yourself with a particular php feature doesn't mean the feature is at fault
 
hehe - for sure, php is imo just an extreme example. i`m not a php user though..
 
12:27 AM
Hey there
 
hi
 
hi all
 
hi @Miss
 
is there a driver for microphone..i mean we need a driver for microphone as audio require.
in other words, microphone also require driver.. is it?
hi @dhanke
 
your question is quite meta.. whats your goal on which OS? you question points to a "no" or "yes" which wouldnt help you i guess
 
12:40 AM
can you please just tell me that : is microphone also require driver>?
 
on windows you can grap the audio devices via DirectX for example. codeproject.com/KB/audio-video/cadeviceread.aspx look here for an example
well i guess the audio driver will be needed, yes...
 
i have audio driver but mic is not working.. thats why i am asking..
 
@Miss, i am afraid this is not the hardware-support channel. no clue..
 
ah ok but people can suggest if they know any solution to a problem,.. anyways thanks
 
and when you found that channel, ask with naming what you tried, on which Operating System, and so on..
 
1:05 AM
@JerryCoffin he's really the only user that made me wish I could ignore specific people
 
1:32 AM
i`m sorry if you are pointing at me, Fred.
Question: div. langauges support features like calling a Class via String, or even methods by String (objc for example). does C++ also features this? i`d really google if i knew how this feature is called.
 
2:02 AM
good evening
@dhanke I think he's referring to There is nothing we can do
 
whew :)
 
@RonaldLandheerCieslak I certainly was, and I'm pretty sure Fred was as well.
 
@dhanke I wasn't, click the arrow to the left of the message to see what it was replying to
 
seems like i had a disconnect meanwhile
 
@dhanke It's most often called reflection. C++ has a few things that could be viewed as a very limited form of reflection, but not nearly that much.
 
2:11 AM
thanks @JerryCoffin
 
@dhanke you can map strings to functions (e.g. std::map<std::string, FuncType>) and get that functionality
mapping to types (at runtime) requires wrapping the type in a function, e.g. a factory that has functions creating a new instance
 
don't know if I'd recommend it, but Google dug this up: garret.ru/cppreflection/docs/reflect.html
 
i just wondered, i obj-c for example, i could e.h. read a name from Database, lets say "FooController", now, having this string, i could try something like, and i write it in pseudo-c-style, since i dont know how well you know object: Class c = ClassFromString(myString); Object *x = [c new];
 
@FredNurk Yes, but regardless of the motivation, making such a rule would constrain others.
 
Qt uses a preprocessor that generates this kind of information
 
2:13 AM
@dhanke a factory pattern will do that
 
@JerryCoffin I did clarify: it's not the feature I want to deprecate, but the syntax/default-form
 
an, @RonaldLandheerCieslak good point
 
@FredNurk I wouldn't deprecate default-form either: it would break a lot of code
 
@RonaldLandheerCieslak does this force the Factory-Class to "know" all of the possible Objects that can be returned? or do i just have to stick down to base-class every Factory-retruned-object belongs to?
 
@dhanke as long as you can create instances from identical function interfaces (such as a common base class), that's not hard in C++
 
2:14 AM
@dhanke I'm not sure I understand your question..?
 
@FredNurk Yes, but I don't think it makes much difference. It's the sort of thing that could (perhaps) have been done in 1990. About the only way to even give it serious consideration today would be in a new/different language.
 
@RonaldLandheerCieslak thats fine, @FredNurk replied to it yet ;)
 
@dhanke yes, string-type (actually function-creating-instance-of-type) pairs must be known to the factory
 
@FredNurk though they could be added dynamically at any time during program execution - depending on your implementation, of course
 
good to know, thanks
 
2:16 AM
sure
@RonaldLandheerCieslak deprecation is not removal; code wouldn't be broken until the syntax is actually changed
 
I guess I should add that deprecating it, per se, isn't a problem -- but I can't imagine them ever taking the next step and actually removing it (probably ever). Even features that are universally agreed to be horrible (which I don't think includes this one) take forever -- e.g., Hollerith conversions were deprecated in Fortran 77, but still present up through Fortran 90 if memory serves.
 
@FredNurk right you are
 
@JerryCoffin I was (happily) surprised that export was removed :)
gets is still only deprecated though :( (or is it? can't recall, but it should be fully removed)
 
@FredNurk it would have been nice if it were just changed to be actually useful
@FredNurk is it?
 
@FredNurk Likewise. I think the fact that everybody was pretty sure export had never been used helped a lot in that regard. I'm not sure gets is officially deprecated, but yes, it should be too. It's the kind of thing that everybody agrees is awful, but it's still not gone, and probably won't be very soon either.
 
2:21 AM
@JerryCoffin personally, I think the whole IOStreams design is awful
3
 
Doing a quick check, I can't find anything to say gets is deprecated, at least as of C99.
 
gets I can live with
 
@RonaldLandheerCieslak I can't agree about the whole design -- it does have some good points. It has some serious problems, but I've yet to see anybody come up with an idea for a dramatically superior replacement.
 
even POSIX says "It is recommended that the fgets() function should be used to read input lines."
@JerryCoffin Well, this has been discussed here before, but one thing that could be dramatically changed is the way text files are handled and the way binary files are handled
one thing that came up was that some systems need to know which is which for some hardly fathomable reason, but aside from that, a filtering approach would work quite nicely, I would think
I kinda like the way OpenSSL handles its BIOs - something along those lines but type-safe and more C++-ish would be nice
 
the reason is fathomable: newline translation to/from \n
 
2:25 AM
@RonaldLandheerCieslak There are lots of things that could be changed -- but to meaningful, you need to come up with a better design, not just a vague notion that this part or that isn't exactly how you'd like it.
 
@FredNurk that doesn't mean the container (i.e. the file system) has to know about it
 
the file system doesn't know about it
 
@FredNurk the point was made that some file systems do need to know about it - though I wouldn't know which, and I can't fathom the reasons why it would need to know
that's the "unfathomable" part
 
@RonaldLandheerCieslak For some systems, it's easy to fathom. We're mostly used to Unix and Unix-like systems, but on others (e.g., IBM mainframes) files have a lot more intrinsic characteristics instead of always being just a stream of bytes.
 
oh, some systems store text files as multiple records of lines
 
2:27 AM
that would certainly account for it..
might make searching easier, perhaps..
anyways, support for something like that would render it impossible to just treat \n conversion as a filter
 
@RonaldLandheerCieslak Yes -- though they're (thankfully) long since dead and gone, once upon a time, I did work on a CDC mainframe that stored text files like Pascal strings: an integer holding the length, followed by that many bytes of data.
 
@JerryCoffin really? wow!
 
@RonaldLandheerCieslak Yes -- and since it started out oriented toward Hollerith cards, the maximum length of a line was 80 columns! I should add that there was a bit more to things than that -- it had several intrinsically different types of files, none of which was quite like how C normally views files.
 
@JerryCoffin would any of that be supportable with C (or C++) then?
 
"80 columns" remind me of this "printing" :)
 
2:37 AM
@RonaldLandheerCieslak It wouldn't be easy. For starters, it normally used 6-bit characters, but C and C++ require 8. You could have used 12-bit characters instead, but it would have taken some work. The file system part probably would have been a bit easier (if memory serves, you could have come pretty close with what it called an indirect file). I have a hard time remembering the details though (that was all around 3 decades ago...)
 
sounds like fun :-)
 
@RonaldLandheerCieslak There were definitely some fun aspects to it -- but a lot of it was pretty painful too.
 
lol
gotta go - good night :-)
 
@RonaldLandheerCieslak G'night.
 
Regarding "Bits" and "Bytes", ppl kind of laughed at me, for using "byte" and "short" instead of "int" for example, i was trying to use types that fit in case, not types that will fit for qute every case. Explaning this, all i got was, that i would not matter anymore today. is that right? As i got into programming, 8MB Ram were normal, so maybe a bit outdated. but is it really equal today, if i use hige or small datatypes for small needs? i did not wrote "low level" (below scripting languges)
for years now
in these scripting languages there was no choice to make
 
2:43 AM
@dhanke in some embedded systems, it can make a real difference
 
ok, in that case it was an iphone, so not really embedded
 
@dhanke There is no one answer. Yes, there are times it's useful to minimize memory usage. Most times, you gain more by minimizing CPU usage, typically by using the "natural" size for the processor. Ideally, you write most of your code so you can switch from one to another easily at need (e.g., typedefs).
 
@JerryCoffin yes, but if you do that, watch out for integer overflows
which won't turn up if you use the larger types, but will if you switch to the smaller ones
and can turn into endless loops (producing output like this)
 
@RonaldLandheerCieslak Yup, quite true. Often useful to do testing with a class that catches them automatically, and only switch to the underlying type when/if you're sure it's safe.
 
really gotta go now - g'night :)
 
2:48 AM
gnight ;)
 
 
1 hour later…
4:14 AM
hey guys
In if condition if ( a || b ), how C++ run
they check a first, if it is true then they go
or they check both a and b ?
then a || b ?
 
If a is true, it skips b.
It only checks both if a is false.
 
Yes, the official terminology is that there's a "sequence point" between evaluating the left and right operands, so it evaluates a, then if and only if a is false, it evaluates b. && is the same, except b is evaluated if and only if a is true.
 
thanks
 
look up short-circuiting
 
Als
Hey All
 
4:36 AM
Hey Als, how's it going?
 
Als
@JerryCoffin: Monday morning Blues.....! You still enjoying the weekend eh..
 
Still weekend, but I'm doing laundry, which isn't the height of excitement...
 
Als
@JerryCoffin: Exciting than a Monday though ;)
 
@Als Maybe...I used to have a friend who always claimed that it was Tuesday that was the real problem though...
 
Als
@JerryCoffin: I happily end up pushing stuff for Mondays on Fridays and then sulk about it on Mondays :)
 
4:47 AM
@Als Ah, now I can see how that could pose a bit of a problem...
 
Als
@JerryCoffin: We all indulge in our own guilty pleasures ha..
 
@Als As rarely as I get to indulge my pleasures anymore, I rarely feel guilty about it... :-)
 
Als
:)
 
regarding that question if @nXqd: do the compiler try to optimize it? i ask because instead of if(a && b) c(); i could write: ((a && b) && c()); (iirc) even though its bad style i guess.. if it gets "optimized", it could become (c() && (...)), or will this never happen?
 
@dhanke If (for example) the compiler can determine that a && b will always be true (and neither involves a volatile), chances are pretty good that it'll optimize the code so it doesn't get evaluated.
 
4:59 AM
so but if a && b are completely runtime determined, it wouldnt?
 
5:28 AM
@dhanke That would be a lot more questionable. About the only way to be sure for a specific case is to look at the code the compiler produces.
 
5:43 AM
okay, turns out that just using if () then; is done faster :D
 
5:57 AM
g2g, @JerryCoffin, @FredNurk thanks for all your answers!
bb
 
@dhanke valid optimizations don't change the meaning of the code, so you don't have to worry about that
in practice, you sometimes run into optimizer bugs ("invalid optimizations"), but it's extremely rare
 
thats nice to now! :) as i said, g2g, have a nice day everybody!
 
 
1 hour later…
sbi
7:07 AM
7 hours ago, by Jerry Coffin
The C++ committee is much more interested in suggestions that support new types of programming and add capabilities, not ones that work toward limiting the language to a few people's ideas of what would force people to write better code.
@JerryCoffin Much of what's been added to C++ (explicit, const) was an attempt to limit the possibilities to shoot yourself in the foot. I'm sure that Stroustrup doesn't like implicit conversions, but we're stuck with them.
Anyway, I think that question is a valid one, and it was closed too hasty. Voted to reopen.
4 hours ago, by Fred Nurk
@JerryCoffin I was (happily) surprised that export was removed :)
@FredNurk I wasn't. For al lits limitations, export at least provided one benefit: it prevented you from recompiling the whole world because you changed one little helper template that's only used by one little helper template which is used by only one template that's used by everybody. At least, Vandervoorde said it does that. I remember going nuts over things like this in an app that took an hour to compile and link.
@AProgrammer Had the focus on the wrong window when typing that? :)
BTW, have you guys seen the discussions on this one:
3
Q: Paying for training when resigning?

Nico HuysamenHi Programmers Community. I came across the following predicament during the past month when an employee at my company resigned. It is the company policy that when you resign, all training that you have undergone during the year prior to your resignation, you have to pay back. This is all good,...

 
@sbi Right.
 
sbi
@AProgrammer Thought so. Do you like Perforce?
 
@sbi it could help compile times, but not link times, and with it, link time really subsumed a lot of compilation duties, so what you got to cut out was only source lexing/parsing
I suspect that could still be a significant savings, even though smaller than you'd at first think
I'd rather focus on a real module system instead of TUs
 
@sbi Not too bad. I went through two in-house systems (one of them build over rcs), clearcase, cvs and perforce. The one I liked best was clearcase, but it has its problems, and perforce is my second choice. I've played with svn and some dvcs (git, mercurial), but not in an working setting. I'm not sure how the dvcs would scale at work.
 
sbi
@FredNurk In that project, compiling on a single core (dual cores were ridiculously expensive back then) took 50mins, linking 10mins. Working with string handling templates (used everywhere) drove me nuts until we ran into IncrediBuild. Link times where still bad, but compile times made this tolerable.
 
7:16 AM
@sbi nice!
 
sbi
@AProgrammer A company I was working for once considered using it, but then went for SVN. Thanks for giving your opinion.
 
@sbi I've mixed feeling. I liked export and I regret that what it provided is no more available. But, IMHO, implementers had mostly vetoed it out. Bringing the standard in phase with the reality was the good choice.
 
sbi
@FredNurk Yep, but export would make this a built-in trait of the language, rather than something external tools provided. (And IncrediBuild wasn't exactly cheap.)
 
no, the "nice!" was in response to something else
 
sbi
@FredNurk Oh, now I see.
Do you find it nice that developers have to pay for seminars?
 
7:19 AM
no, that his company was running itself into the ground and considered it 1) standard practice and 2) beneficial
and sarcasm doesn't always come over text well :)
 
sbi
@AProgrammer As I know the tale, EDG struggled a lot to prevent it from being voted into the standard, then was the first and only vendor to undergo the pain of implementing it, and then proposed to deprecate it. Although I like the feature, there's no way I could argue with those guys.
@FredNurk Indeed. Sorry for being so dense.
 
I've recently tried darcs and I must say it looks pretty nice to me. I particularly like how the author went as far as to develop a whole algebraic theory of patches.
Never seen darcs used in production, though.
 
Darcs is nice for small stuff.
 
last I read, darcs doesn't scale
 
morning all
 
7:22 AM
I hear it had some performance issues and git is much, much faster
 
cpx
@TonyTheTiger morning.
 
@cpx hi, how are you this morning?
 
cpx
good. how are you?
 
sbi
@GrigoryJavadyan Whatever I hear about regarding any VCS, be it a feature everybody loves or something driving them nuts, I always hear that git is much, much more so.
 
@cpx I'm well :)
 
7:26 AM
@sbi You forgot the long phase between EDG implementation and their proposal to remove it when some lobbied a lot to remove it with false arguments. My perception is that EDG pov is "As long as the other implementers won't implement it, let's remove it so that we don't have to maintain it" even if it is formulated more politely.
 
sbi
8 hours ago, by Martinho Fernandes
@CatPlusPlus What's that cat/Perl thing?
@MartinhoFernandes Perl always looks like the cat's walked across the keyboard.
@AProgrammer I see it the other way around. That feature took real pains to implement, they offered help and advice to any implementer doing it, they are the only ones providing it, and then they propose to sparing their competition the trouble to implement it, too.
 
@sbi hahahahah :p
why are we talking about VCSs?
 
@tony, I typed a perforce command while having the focus here instead of a terminal window...
 
@FredNurk welcome back! We can go back to multi-fredding now, hahah :p
2
 
:)
 
7:33 AM
@FredNurk you alright?
 
no, but no worse than I was last time you saw me here
 
@FredNurk oh k
 
@sbi Not sure. I think that part of the problem for other implementers is that export depend on the iterated instantiation model to bring most of its benefit, while most compilers are using the greedy one.
 
anyone heard of this
In computer operating systems, read-copy-update (RCU) is a synchronization mechanism implementing a kind of mutual exclusion which can sometimes be used as an alternative to a readers-writer lock. It allows extremely low overhead, wait-free reads. However, RCU updates can be expensive, as they must leave the old versions of the data structure in place to accommodate pre-existing readers. These old versions are reclaimed after all pre-existing readers finish their accesses. Overview RCU features read-side critical sections, which are normally delimited by rcu_read_lock() and rcu_read_unloc...
 
@tony, yes. Never used it.
 
7:47 AM
@AProgrammer just trying to understand what it is and how it works :)
 
Als
hmm
 
8:03 AM
anybody know what value-speculation compiler optimizations are?
 
@TonyTheTiger Do you have a specific question?
 
@AProgrammer yes the one just above?
 
@TonyTheTiger Educated guess: computing a value hoping it would be beneficial to do so (for instance using otherwise free slots in a superscalar processor).
Those kind of expressions have a very specific meaning for some and a totally different one for other.
 
@AProgrammer hmmm ok
well it came out of this article
 
8:18 AM
They describes what happens with that optimization in their context: guessing a value (probably guessing it is the same as a value already in a register), using the guess while the read is in progress. This can help if the value has to be read from main memory (access time in the 100 of cycles) but the use access L1 or L2 caches (access time of around 5 or 15 cycles).
 
@AProgrammer so they prematurely guess the value so the cpu can continue while it is being fetched from main memory... that's what this optimization is all about, in this context?
@FredNurk, @FredOverflow = Multi Fredding! :p
 
Yes. Accessing memory is the bottleneck for most application. Processor and optimizer designers are putting a lot of effort in hiding the latency by doing things out of order (not in the same order as in the program) or speculatively (guessing and committing only if the guess is right).
 
Als
@TonyTheTiger: Theres another @Tony who lurks in the main C++ SO...
Thankfully, this Lounge is marked your territory i guess..Only you prowl here ;)
 
@Als Never seen another Tony in this room, but I do know about the other one prowling the C++ tag
 
8:33 AM
Leaving some code uncommited on Friday is good because it's easier to pick up on Monday.
Just discovered this.
 
Als
@TonyTheTiger: But you are the lone tiger ;)
 
@Als that's why I changed my name, to differentiate and yes I am the one and only tiger around here :p
 
8:52 AM
@TonyTheTiger Do you eat Frosties for breakfast? :)
4
 
@StackedCrooked I don't eat bf
 
@TonyTheTiger That's a bad habit. You're just like me.
 
@StackedCrooked I know, trying to break it
but failing at times
 
@TonyTheTiger I just fail to have food at home.
 
9:11 AM
@StackedCrooked lulz
 
9:38 AM
@ all Hi
anyone here worked on OpenXML SDK?
 
on or with?
 
sbi
@Als @Tony Using multiple Tonys (or is it "Tonies"?) is called overtoning. :)
@StackedCrooked I don't think I've done this in years. Having seen too many HDs fail, I always check in anything taking longer than one day. I'm creating lots of branches to do that.
@FredOverflow I'm usually on a chair while working. :)
 
9:55 AM
@FredOverflo sorry 'with' I meant
 
sbi
@TonyTheTiger Break it fast!
@StackedCrooked You might benefit from having explained the concept of "shopping".
Oh my. I have finally rebootet my laptop this morning, because Windows update kept nagging me about 35 updates it wanted me to install, but when I wanted to look at the list of updates it always came up blank. So I rebootet and, indeed, the list then showed all the updates. Now I'm waiting for >600MB of updates to download, install, and request rebooting again... which makes for a foul mood and many not so funny comments. I apologize, but I can't help it.
I hate rebooting. The last time I did it must have been in February or March, when I last installed updates.
The trouble is that everytime I bite the bullet, install all the updates (Windows, Java, Acrobat...) and reboot, it takes about 20mins for some stupid app popping up a dialog requesting to be updated...and reboot.
Hi Piotr++, do you reboot?
(And did I mention I'm in a foul mood?)
Well, I got to reboot. Hopefully see you soon...
 
@sbi This PC I do, wireless driver is acting funny if I hibernate it.
 
10:11 AM
@sbi Hadn't thought of that. But, since I have a compulsive habit of committing frequently, it probably wouldn't be a big loss.
Damn, I think I made a big mistake in committing myself to clean up a heap of legacy code.
 
hai
 
@sbi hahaha :)
 
why is it people think that new people should be given C before C++?
4
C++ would enable them to write far superior code
 
@DeadMG because those that think that obviously don't see the advantages of C++ over C imho
 
yeah
or the suggestion that if OO was important, then C# or Java should be used
their OO is pathetic
 
10:24 AM
or they want to teach them C concepts (subset of C++) to then go to C++, but it doesn't necessarily make sense
@DeadMG elaborate?
 
well, I was having a discussion on gamedev.stackexchange.net
this guy says, I want to write a game for the first time, yadda yadda, I'm looking at OpenGL and C and some other stuff
and I said
well, C sucks compared to C++, don't use it unless you genuinely have to, and OpenGL has a crappy non-OO interface
both of which are completely true
and then this guy goes
 
@DeadMG Not subjective at all.
 
omg, C is better for new people, and if OO was important, he should use Java or C#
 
Trying to win language wars is a lost cause.
7
 
yeah
I know
honestly, I wouldn't care about these people who are zealots about C, if they didn't try to kill other people by spreading it around
 
10:28 AM
@DeadMG but they could say the same about you spreading the C++ message
so essentially it's a sill war
 
no, not really
it's pretty difficult to argue, objectively, that you can program better in C than in C++ when C++ completely supports C-style programming, but not vice versa
 
@DeadMG I'm sure the C zealots have their "reasons" for not using C++ and could rant for hours about it
 
or that C's approach to resources is not flat out worse than RAII in pretty much every conceivable fashion
they do, I've seen them, and it boils down to not liking some specific features
but that's a moronic reason not to use it because if you don't like it, you don't have to use it
if you hate exceptions, you don't have to not use RAII or templates or something
 
@DeadMG true, but I guess they think differently about that
 
you can just not use exceptions
yeah- because they're moronic
 
10:30 AM
@DeadMG I guess if you say so, It's gotta be so! :P
 
I like to think so, personally
 
@DeadMG hahah :P
 
what? it's obviously my opinion that my opinion is correct, else it wouldn't be my opinion
 
maybe we should change the room topic to: Where C is not a subset of C++ LOL
 
why would you do that?
 
10:32 AM
@DeadMG of course, but your opinion, by the mere definition could also be wrong, even if you think it is right
@DeadMG for fun
 
I'm pretty sure that it's an objective fact that C++ supports C-style programming
 
@DeadMG that is true, yes
 
and also an objective fact that it doesn't take exceptions to use RAII, or RAII to use templates, or any other of a dozen great C++ features
those are facts, and not at all subjective
 
@DeadMG but the great C++ features is where you think they are great, they may not be great in those C zealots minds...
 
and the fact is that if you dislike exceptions, you can still take advantage of RAII or templates or any dozen other improvements
 
10:34 AM
@DeadMG true that
 
a good chunk of those are objectively great too
but you'd have to be pretty moronic to think they're all bad
 
@DeadMG how does something become "objectively" great? I thought greatness is a matter of opinion... maybe I'm wrong
 
well, for example, take RAII
how is that not objectively better than manually freeing resources?
 
yeah
 
10:55 AM
hi
i have a very simple probem. how can i avoid std::string memory leak?
 
Exactly what leak?
 
@omnosis by doing nothing
 
standard string
i have this simple program:
#include <string>
int main(void) {
std::string watta;
_CrtDumpMemoryLeaks();
}
 
@omnosis An std::string handles its own memory management. It doesn't leak.
4
 
and this gives me memory leak
 
10:59 AM
@omnosis It's not a leak.
 
@StackedCrooked it does
 
The memory is not freed, because the string it's still alive, it's not a leak.
 
and then how to destruct?
 
Don't trigger leak reporting when the program is still running. CRT can dump the report automatically after main exits.
 
You should try this:
int main() {
{ // start a new scope
volatile std::string test; // use volatile to avoid the compiler optimizing it away
} // end of scope, string is destructed
_CrtDumpMemoryLeaks(); // now you can test for leaks
};
 
11:03 AM
Optimisations are probably off, anyway, since he's using debug CRT.
 
@StackedCrooked ah. it works.
 
@CatPlusPlus It's just to be sure, some optimizations (like RVO) also appear in debug builds
@omnosis PS: don't use volatile in your code
 
i didnt. but the new block was a good idea
 
Lol, I notice that I typed a semi-colon after my main function. This is one of my pet peeves in other people's code.
Would it be a sin to wish for more metadata abilities in C++?
Like the ability to get a string representation of an object (similar to GDB's pretty print).
 
anyone help me in openGL
?
 
11:32 AM
Can you do volatile std::string and use any member functions? Since the member functions are at best const it should complain about not finding any suitable overloads, IMHO.
 
@wilx Why not? volatile is a hint to the compiler that it shouldn't assume too much about the variable.
 
@wilx What is the point of declaring an std::string as volatile may I ask?
 
@GrigoryJavadyan what's the point of anything?
 
@TonyTheTiger everything?
 
@TonyTheTiger I was asking seriously :) What effect will volatile have if applied to an std::string?
 
11:44 AM
@wilx You need to mark the member function as volatile as well then.
 
The same effect as applied to any other type.
 
void getString() volatile {..}
 
@jalf not a bad answer
 
@wilx Or use const_cast to cast the volatileness away.
 
"the volatile keyword is intended to prevent the compiler from applying any optimizations on the code that assume values of variables cannot change "on their own." Hmm, I guess there is sense in declaring strings as volatile... My understanding of this keyword was wrong.
 
11:52 AM
volatile is there to ensure that accesses at the abstract machine level are kept. It is useless with anything other than fundamental and pointer types.
 
Ok, if we have a struct Foo {int a; int b;}; and volatile Foo f;, can we say that the compiler treats f.a and f.b as volatile?
 
no
yes
 
Then volatile is also useful for something other than basic types and pointers :)
 
volatile and const are identical in the type system
 
@DeadMG What do you mean by that?
 
11:57 AM
well
anything that you know about const propagation or the rules for calling const member functions, they are the same rules as volatile
the Standard calls them cv-qualifiers, because it's for both const and volatile
 
00:00 - 12:0012:00 - 00:00

« first day (198 days earlier)      last day (4733 days later) »