« first day (211 days earlier)      last day (4728 days later) » 

2:00 PM
@FredNurk The fundamental difference is that T& x = ... does not promise to lengthen the lifetime of temporaries.
(Whereas const T& and T&& do.)
 
"rvalue-refs are too hard to use, so don't use them" is not justification
something is not "unnecessary obfuscation" when it is the only solution to the problem at hand
 
@FredNurk I don't think anyone is arguing that; possibly there is a an argument that "rvalue-refs as return parameters are dangerous"
 
and, let's face it, this will be premature optimization 99% of the time, but it will actually matter for some people
 
@FredNurk I agree 100% with this and my only beef with your answer is that you don't put any caveat in it
 
@LucDanton Howard is arguing that "if [this use is] 'deemed' correct will just add huge amounts of confusion to rvalue references"
 
2:02 PM
Which doesn't mean that rvalue-refs are hard right now
 
@LucDanton I don't always put such a caveat in, even though I do 90+% of the time; depends on the level of understanding I see from the poster
 
@FredNurk I'd like one for the sake of others
 
feel free to comment to that affect; I'd upvote that :)
probably better as a comment on the question
 
@FredNurk I was thinking that actually
stackoverflow.com/questions/5770253/… is already linked to the question though; what does that mean? (found an explication)
 
it was posted as a link somewhere; in Fred's answer, I believe
 
2:09 PM
Perhaps @FredOverflow should repost his link as a comment to the question; the code in your answer mimicks the question after all
 
@LucDanton: actually, my answer did include the caveat: use the canonical form of T op+(T, T const&) and optimize it only after you see a need :)
 
It's the "To completely avoid all possible copies/moves, you would indeed need these overloads:" bit that I find problematic, since some of the overloads return vec&&
It looks too innocent
 
they return vec&& because that's how you avoid the copy/move
 
@FredNurk Are you sure returning a parameter by value implicitly moves it? I seem to remember Doug Gregor telling me that this is not the case.
 
@FredO: It does, how else would you return movable-only types by value?
std::unique_ptr<int> func() { return std::unique_ptr<int>(nullptr); }
 
2:17 PM
@DeadMG by explicitly moving them
 
@DeadMG By explicitly casting to an xvalue via std::move?
 
sure, but that's redundant because you know that it's not a copy
 
FDIS §12.9p32; "...or would be met save for the fact that the source
object is a function parameter, ...overload resolution to select the constructor for the copy is first performed as if the object were designated by an rvalue."
which means it will find a move ctor, if there is one
 
@FredNurk I know that, this is the part that needs a big warning
(re: returning vec&&)
 
well, I don't see why not just return it by value
it's not like you'd make a copy that way
 
2:22 PM
@LucDanton why? "On the risk side, [T const &x = a + b + c;] is pretty rare. I don't think I've ever seen it." to borrow Howard's words
 
"You ain't gonna need it" + "premature optimization"; I don't think anyone should be afraid of returning values. Move constructors are intended to be cheap; let the compiler remove the calls, not the programmer
 
@DeadMG the point of the original question was to avoid both copies and moves, not to merely elide them nor to turn copies into moves
 
hm
 
@LucDanton again, intended but not always, Howard uses such an example to justify his rvalue-ref returning: array<int, N>
 
@LucDanton I find his example of move iterators more motivating
I don't dispute that there are cases
I want to dispute the fact that it shouldn't be approached with caution
 
2:25 PM
what in C++ shouldn't be approached with caution?
even simple integer manipulation is fraught with peril
 
And I expect answers to put caveats where appropriate, yes
 
I am just completely shocked that Howard expects people to use his code correctly because they're smart, yet users of my code don't get that luxury: it's too complicated to be understood and we must protect them from writing idiotic code
 
His answer starts with "There are a few occasions when it is appropriate, but they are relatively rare."
Do you mean his comments on your answer?
 
yes
 
Well your answer doesn't have a disclaimer (you do suggest a canonical form which I find a-ok); I don't see an inconsistency
 
2:29 PM
@FredOverflow: I purposefully formatted it that way
 
0
Q: Are value parameters implicitly moved when returned?

FredOverflowConsider the following function: Foo foo(Foo x) { return x; } Will return x invoke the copy constructor or the move constructor? (Let's leave NRVO aside here.) To investigate, I wrote a simple Foo class that is only movable but not copyable: struct Foo { Foo() = default; Foo(cons...

@DeadMG I posted a question on SO, let's see what the experts say.
 
that's a bug that's known in MSVC, the same might apply to GCC, where the compiler attempts to ellide a copy even when it could move
you should check std::unique_ptr instead of a custom class
 
@DeadMG In the general case or just for parameters? GCC does the right thing for local objects.
 
I think it's in the general case
MSVC wants an accessible copy constructor to ellide the copy, even when it could move instead
 
@DeadMG Same error with std::unique_ptr here...
 
2:33 PM
then it's non-conformant
 
@FredNurk Interesting, the quote explicitly mentions "save for the fact that the source object is a function parameter"...
(But I didn't read the quote carefully.)
 
it's exactly what I quoted earlier here
function parameters don't otherwise qualify for copy elision; they are explicitly excluded
so that brings them back in
 
@FredNurk Ah, that kinda clears things up. Can you edit that into your answer?
 
@LucDanton what should I disclaim? "don't use this to write dangling references, even though you'd practically have to do so on purpose to get them"
 
@FredNurk "This is an expert use" or "Make sure you need this before you do it" or "Make sure you understand what it does"
You don't have to say why
(I don't think it's that dangerous, but I find it unncessary)
 
sbi
2:38 PM
@FredOverflow BTW, @jalf or @Dead (after my retagging last night) could now suggest c++0x to become a synonym of c++11, and five of this room's regulars could upvote that suggestion. (stackoverflow.com/tags/c%2b%2b11/topusers) Suggestions will be automatically approved when they reach a score of 4.
 
Perhaps it's just the functional programmer in me that wants to return values...
 
oh, I think that C++11 s now a synonym of C++0x
not the other way around
 
@sbi Where do I sign?
 
sbi
@DeadMG That's nonsense. Do you want to read C++0x ten years from now, or C++11?
 
yeah
it is, but that's how it is right now
oh wai
no it isn't
 
2:40 PM
@LucDanton I do say "don't do this before you know you need it"
 
sbi
@FredOverflow Here, after somone suggested it.
 
sbi
Oh, wait. you need 5 answer scores. Not sure you all have that. But if so, you could even suggest it, not only vote on it.
 
@sbi I don't have enough C++11 rep :(
 
who unpinned the "tags in page titles" note?
 
sbi
2:43 PM
@Xeo Yeah, but all it takes to remedy that is one more downvote at stackoverflow.com/tags/c%2b%2b0x/synonyms. <hint/>
@FredNurk I dunno, but I pinned it back, because it seems important to you.
@FredOverflow Oh, that's right, you aren't on the list.
 
Xeo
@sbi Done, now it's at -1
 
@sbi: thank you; it's something that seriously annoyed me for the longest time, and I finally found a fix, and I know I'm not the only one that hates it
 
I'm confused, which synonym do we want again?
 
Xeo
C++0x shall map to C++11
3
 
Damn, the tags c++ c++-faq c++0x c++11 only leave room for one additional tag :-/
 
2:45 PM
Which one should be the master?
 
@LucDanton He-Man
 
sbi
@Xeo Then someone must have upvoted it right now, because it was at -1 after I had downvoted a few mins earlier.
 
@LucDanton of course
 
@MartinhoFernandes So stackoverflow.com/tags/c%2b%2b0x/synonyms isn't the way to go is it?
 
2:47 PM
@sbi: isn't it a bit of premature optimization to start enforcing a c++11 tag?
 
Only jalf, DeadMG, Anthony Williams, Xeo, FredNurk, and rlc can do it the right way.
 
Xeo
@FredNurk Why enforce? It's just a synonym
 
casual chat, even answers and comments, are one thing, but to force everyone on the site to no longer tag as c++0x?
@Xeo accepted synonyms (score of +4) are enforced
 
Xeo
Oh, so if I wanted to tag my question with C++0x (because I don't know of C++11 tag), I couldn't ?
 
You can tag it c++0x, and the system transparently maps it to c++11.
 
2:49 PM
@Xeo synonym tags are silently renamed to the "master" tag
 
Xeo
Well, where's the problem then?
 
sbi
@MartinhoFernandes Which does make sense, actually, because it is C++11.
 
@sbi it's ratified and published already!?
 
Xeo
the FDIS is finished and now only the ISO comittee's approval is missing I think
 
sbi
Remember, C++0x was a temporary name to be used before we knew the year. We now do know.
 
Xeo
2:50 PM
so it should be official later this year
 
@Xeo the voting process from each country, then publication, is what's missing
 
sbi
@FredNurk What's missing is a final vote from all these who already voted positively on the FDIS. AFAIK, this is scheduled for September.
But if it fails, we can always make c++11 a synonym of c++12. :)
3
 
@sbi ever heard of expecting parents finding out the sex of their baby early? buying clothes, painting, and so forth; sometimes the ultrasound was misread
@sbi "we now do know"... do we really?
 
Can a synonym be un-synonymed?
 
@LucDanton only if you bug a moderator and convince them
 
2:52 PM
Can synonyms be circular?
 
@FredOverflow no
 
it's just a proposal now, so you can downvote it
 
@DeadMG Where is the proposal?
 
on the C++0x tag page
 
sbi
@LucDanton Yes. When it has a score of -2 it's automagically deleted.
@FredNurk That's wrong, actually.
 
Xeo
2:53 PM
We absolutely positively need a moderator in the C++ group present in this room
 
no, we don't
 
@DeadMG NO! That's the wrong proposal.
 
@DeadMG You mean here? I don't see it :(
 
The correct one is the one that will be on the c++11 page!
 
sbi
@DeadMG But that isn't what I propose, it's the opposite, and doesn't make sense.
 
2:53 PM
you have to downvote it and get it removed
then propose C++0x to be a synonym of C++11, not the other way around
 
@DeadMG Okay that worked, but nobody has suggested the other synonym yet, right?
 
Xeo
C++0x synonym of C++11, voting here -> stackoverflow.com/tags/c%2b%2b11/synonyms
 
sbi
@FredOverflow Great!
 
now upvote
 
sbi
2:55 PM
@DeadMG I wish I could.
 
why can't you
 
sbi
Anyway. Gotta go. See you later.
 
> You do not have the required score on this tag to vote for this tag synonym
:-(
 
Can't you just retag some old question and "cheat" your way in?
 
Xeo
see ya @sbi
 
2:56 PM
@MartinhoFernandes I already did it, maybe not enough.
 
@sbi how are synonyms unlinked without a moderator?
 
I think I need five different answers upvoted in C++11.
 
Xeo
@FredOverflow total score = total number of upvotes - total number of downvotes, so one +5 c++11 answer should suffice
 
@MartinhoFernandes yes, but those stats are updated by a cron job instead of instantly
 
@Xeo Apparently, I don't have that yet.
 
2:57 PM
yeah, it's any +5, not 5 separate answers
 
9 mins ago, by Martinho Fernandes
Only jalf, DeadMG, Anthony Williams, Xeo, FredNurk, and rlc can do it the right way.
 
where can you see the list?
 
Xeo
@MartinhoFernandes Gotta admit, I was surprised I was allowed to propose the synonym
 
hey, I am the (nearly) greatest C++11 answerer
 
2:59 PM
@MartinhoFernandes I'm not even on the list? Seems the retag cheating either doesn't work at all or takes some time.
 
@DeadMG rep and answers are overrated
 
yeah
especially in a tag like C++11 which is so fresh
 
Xeo
Boo, who downvoted the proposal of the C++11 synonym?
 
wtf, who downvoted the synonym vote?
 
Xeo
lol
 
3:01 PM
Sigh, this is going to take a while.
 
well, you guys should just ask some nothing C++11 question and get mass upvoted for answering it
 
Xeo
@DeadMG Well, at least we can narrow down the culprits. :P
 
@Xeo I did
14 mins ago, by Fred Nurk
casual chat, even answers and comments, are one thing, but to force everyone on the site to no longer tag as c++0x?
11 mins ago, by Fred Nurk
@sbi ever heard of expecting parents finding out the sex of their baby early? buying clothes, painting, and so forth; sometimes the ultrasound was misread
I'm starting to use c++11 myself, but I don't think we should, yet, force that on all of SO
 
@FredN: Synonyms don't force C++11 on everyone, you can still use C++0x if you want to
 
@FredNurk Even in that case, we should not be using two different tags.
 
3:03 PM
all it means is that they're no longer separate tags
 
Xeo
@FredNurk Oh, ok, I overlooked that you were on the list. :) Else I would've known
 
@DeadMG no, once it's accepted you will no longer be able to tag c++0x
 
@DeadMG C++11 isn't even official yet.
 
o rly?
 
Is it?
 
3:04 PM
yes, as far as I know
 
@MartinhoFernandes I agree, I'd prefer to tag as 0x for now, but I'm not going on a mass retagging spree
 
but I didn't know that synonyming C++0x and C++11 would prevent people using C++0x
 
@DeadMG synonymed tags are silently renamed
 
Xeo
@FredNurk Well, only 14 question use C++11 tag currently :P
 
well, I don't really see why it's even necessary to begin with
soon enough, C++ tag will be C++11
C++0x was only necessary because it wasn't C++
 
3:07 PM
Hm, good point.
 
Xeo
@DeadMG or rather, C++11 will be a synonym of C++
 
Hello folks
 
@DeadMG exactly, we still have things to figure out before making changes that are harder to undo
 
Maybe we should just get rid of C++11 and later this year propose C++0x as a synonym for C++? Who's with me? :-)
2
 
nah
people will still want to tag the different Standards
maybe they have a specific impl. that isn't upgraded or something
 
3:09 PM
they can use c++03, 98, or compiler-specific tags
 
@DeadMG So what do you propose? Status quo?
 
Xeo
@FredOverflow Sounds good actually, since C++11 will be the normal C++. We don't have different C89 and C99 tags, do we?
 
yeah
so what happens when there's a C++13 bug fix Standard, or another milestone update?
 
@FredOverflow Contrast , , , , .
 
we'd just have to make a C++11 tag again
 
3:10 PM
It's useful to have all those tags.
 
pretty sure that we have C++03, C++98 tags, last time I checked
 
@Xeo yes, we do
 
Xeo
@FredNurk Oh, really? Then leave it as C++11
 
@Xeo Can we rename tags?
 
we already have C++03, C++98 tags
@FredO: Yeah- by voting them as synonym
 
Xeo
3:12 PM
okay, general question. which C#-X.0 tag does the normal C# tag map to?
 
@FredOverflow we can't, moderators can
 
@Xeo None.
 
it's currently C# 4
 
Okay so we currently have c++, c++98, c++03, c++0x, c++11 and c++-faq? That's just stupid.
 
I can see the purpose of all of them, but not for keeping C++0x
 
3:13 PM
just wait until we have the next standard and everyone will want to change it
it's only a few months more, how old is the oldest c++0x question? back to the beta days of SO?
 
37
Q: What's your favorite C++0x feature?

copproAs many of us know (and many, many more don't), C++ is currently undergoing final drafting for the next revision of the International Standard, expected to be published in about 2 years. Drafts and papers are currently available from the committee website. All sorts of new features are being adde...

This seems to be the oldest C++0x question.
 
So we'll probably have three years worth of C++0x questions once C++11 is official.
 
might be one older that got renamed, but also that was originally tagged c++10 :P
 
lol at that comment
Except that it couldn't be. As an ISO standard, it cannot be revised more than once every 10 years. So October 10, 2008 is the earliest that a new standard could be set. Note that the final meeting was in September, expect ratification sooner rather than later. – Zathrus Oct 29 '08 at 21:14
yeah, good luck with sooner rather than later
 
3:16 PM
Will the questions also be automatically retitled to C++11? :-)
 
once every 10 years is misleading if not wrong
 
well, there was C++98 and C++03
 
03 was a TC, not quite a Standard with a capital S, or something like that
(it was, but hopefully you get what I'm saying)
 
yeah
 
> If you know the difference between C++98 and C++03, you have just been reading too many manuals.
Great, now I have the desire to read all 22 pages of C++0x SO questions...
 
3:19 PM
lol
 
Xeo
@FredOverflow Um um um.. the number behind the language name? D:
 
@Xeo Find better manuals!
 
Xeo
Okay, off-topic question, since we're now on-topic for way too long already.
Anyone got experience with Debian Live USB images? :)
 
@Xeo vectors are guaranteed to store their elements sequentially in memory in C++03, that's all I can remember.
Oh, and the concept of value initialization was new in C++03, right?
 
rlc
@Xeo yup
@FredOverflow must be - I don't remember it being in C++98
 
Xeo
@rlc Yay! I tried following the pendrivelinux guide with Win32 Disk Imager, but when I want to boot from the stick it just shows "missing operating system"
 
@FredOverflow Why isn't this inlined?
 
@FredOverflow explicitly guaranteed; I interpreted 98 at the time as implicitly guaranteeing it, because the standard was ambiguous and sometimes you just have to make a (human) decision
 
I'm amazed this question didn't get closed:
11
Q: What do you think about c++ after c++0x standard?

yesraajWhat do you think about c++ after c++0x standard is released.

 
3:22 PM
What's magic about that link?
 
Xeo
 
It does work if you cut it out to the question id. Anything else won't.
 
rlc
@Xeo haven't run into that problem (and I've had quite a few pendrive linuxes) - but I do know some USB sticks don't like being bootable...
@FredOverflow it's tagged as a poll.. maybe that makes it OK?
 
@rlc /off to read all c++ polls :)
48
Q: What is the most spectacular way to shoot yourself in the foot with C++?

TonJIn 1986 or so, Bjarne Stroustrup famously said: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." What is, in your opinion, the most spectacular way to blow your leg off in C++? Points for originality, and for helpfulness.

 
Xeo
1
Q: Why are by-value parameters excluded from NVRO?

Johannes Schaub - litbImagine: S f(S a) { return a; } Why is it not allowed to alias a and the return value slot? S s = f(t); S s = t; // can't generally transform it to this :( The spec doesn't allow this transformation if the copy constructor of S has side effects. Instead, it requires at least two copies (o...

 
3:32 PM
Was @Johannes inspired by my previous question about returning value parameters by value, maybe? :)
 
rlc
@FredOverflow this is a very nice answer though:
51
A: What is the most spectacular way to shoot yourself in the foot with C++?

Michael EasterOriginality, eh? Well how about Multi-Dimensional Analog Literals Tighten your seatbelt and click here There is real code behind these (see bottom of post). I only wish I had an ounce of that much creativity. Example: unsigned int c = ( o-----o | ! ...

 
@LucDanton I think you're right, targeting a wider audience is worthwhile here
 
@rlc Yeah, analog literals are fun. Already knew them, though. Otherwise, I would have been completely mind-blown.
 
Xeo
@rlc I knew them since that question. I think I couldn't move for the rest of the day. :(
 
ok, I have a curious problem
I saw that question about poor overload resolution with std::function, and I've een poking at it
but now my compiler seems to think that the function I'm trying to pass is overloaded when it isn't
 
Xeo
3:36 PM
oO
what's the exact code + error?
 
Anyone knows when C++0x will come? ^^
 
@Robik Probably September this year or something.
 
trying to use decltype to force a substitution failure in the constructor
 
Oh. It's a bit too late
 
3:38 PM
@DeadMG Which headers do I need to include?
 
none
 
error: 'is_same' is not a member of 'std'
 
@FredNurk That is indeed a nice operator+
 
oh
<type_traits>
or you could just use Boost equivalent
 
3:40 PM
Maybe g++'s error messages will help you?
6:83: error: there are no arguments to 'f' that depend on a template parameter, so a declaration of 'f' must be available [-fpermissive]
6:83: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
6:83: error: there are no arguments to 'f' that depend on a template parameter, so a declaration of 'f' must be available [-fpermissive]
 In function 'int main()':
23:17: error: call of overloaded 'func(int (&)())' is ambiguous
23:17: note: candidates are:
 
well, that seems to be more logical
but Visual Studio complains about the argument being an overloaded function
which it clearly is not
 
I think some errors will go away if you replace decltype(f) with Func in the default argument
 
ok
I convinced it to cause an error, but it won't cause a non-fatal substitution failure
 
Xeo
there is a typo
 
it should be decltype(f()), not decltype(f)
 
Xeo
3:43 PM
f(*((A1*)nullptr))
 
I've got this now
 
Ack; too much of a headache to think straight
there also is typename std::result_of<Func()>::type
 
what if operator() is overloaded?
I need the type returned when it's called with the argument types only
a purpose served by decltype just fine
 
Guess how result_of is implemented
 
yeah
it's just easier to use decltype
besides,MSVC doesn't have result_of
oh, it does, just not in the type traits header
 
3:46 PM
decltype(f(*((A1*)0))) easier than result_of?
You could use declval; and then you'd just end up with result_of
 
MSVC doesn't have declval
 
Whoah does result_of work fine?
 
well, I don't actually see how I'm supposed to pass in the types of the intended call
as it only takes one template parameter- the function type
 
[typename] std::result_of<F(A0, A1, A2)>::type <=> decltype(std::declval<F>()(std::declval<A0>(), std::declval<A1>(), std::declval<A2>()))
 
look, result_of (according to it's MSVC spec) is pretty much just limited to function pointers of various types
 
3:49 PM
So my recommendation for result_of is purely base on clarity/intent
 
which is not particularly acceptable
perhaps MSVC just doesn't contain the full specification of it
 
Note that you only need decltype to implement result_of (declval is easy); if MSVC doesn't do it yet it's likely because their decltype can't do it. I think it was changed one last time just in time for the FDIS because it's a bit tricky to specify.
 
declval being easy doesn't mean that it's actually implemented
 
That would be weird
 
if this stuff was specified later than about 2008, then MSVC won't have it unless it's a bugfix or something
 
3:53 PM
template<typename T> constexpr T&& std::declval(); // done
You need a good constexpr too
Can't remember how it was in 2008
 
ok
 
I believe there was a SP1 that improved things though?
 
the real question is, why doesn't the code that I posted previously cause a substitution failure instead of a fatal error?
it was just minor bugfixes
there are a lot of bugfixes, especially in the libraries, that don't ship until VC11 anyway
 
ideone.com/4AOwB works for gcc-4.5 (modulo nullptr)
Is this what you wanted?
 
yes
that's pretty much what I've got, but MSVC barfs on it
 
3:54 PM
I'll instrument the functions just to make sure (<- dumb, there's no operator() yet)
 
Xeo
Uhm, @DeadMG, you forgot the enable_if in your above code?
 
pretty sure that my most recent post includes it
but my code I'm looking at on my screen most definitely has it
 
Xeo
ah, sorry, overlooked that
 
@DeadMG So codepad uses MSVC?
 
no idea?
MSVC doesn't exactly make it easy to use their C++ compiler for anything else, trust me, I've tried
 
3:56 PM
Or did you paste the errors in?
I see
 
I pasted in the error
as requested
1>blank.cpp(6): error C2039: 'type' : is not a member of 'std::tr1::enable_if<_Test,_Type>' is what I've got now
so the TMP is working, but it causes a fatal error, not a substitution failure
 
I'm definitely not confident on using a parameter inside a decltype while still inside the arg list
There is a new way to SFINAE out functions without adding dummy parameters and changing the return type but I don't know if MSVC can handle it
 
rlc
@FredOverflow I don't see how this shoots in any feet, though
 

« first day (211 days earlier)      last day (4728 days later) »