« first day (210 days earlier)      last day (4753 days later) » 

8:01 PM
room topic changed to Lounge<C++>: C++0x is dead, long live C++11
@LucDanton You better get used to those double ampersands ;)
27
Q: What does && mean in C++0x?

paxdiabloI've been looking into some of the new features of C++0x and one I've noticed is the double ampersand in declaring variables, like T &&var. For a start, what is this beast called? (I wish Google would allow us to search for punctuation like this.) What exactly does it mean? At first gl...

 
sbi
@FredOverflow We should retag some c++0x questions to c++11, so that more of us have enough rep in that tag to make c++0x a synonym of c++11.
 
@FredOverflow I had more trouble understanding why and how I needed std::decay tbh
 
@sbi Sounds interesting. How can I see how much rep I have for a tag?
@LucDanton Never heard of std::decay... my gut instinct tells me it removes all references?
 
@FredOverflow "it does the right thing" when you need to store something indeed
 
sbi
8:04 PM
@FredO: I just retagged the one you just posted. That would give @Dead a lot of rep in the tag.
 
I'm still mad about perfect forwarding constructors though; I really hope I got it wrong
 
sbi
@LucDanton When you're mad about perfect forwarding, I'm sure you got something wrong.
 
Interesting, I find several uses of std::decay in the standard, but no definition. How is it defined? Found it, it's on page 600.
 
@sbi Riddle me this: a generic class with a perfect forwarding constructor; do I declare the copy/move constructor or let the compiler do the right thing? What happens when I call T(T())?
 
sbi
@FredOverflow There used to be a definition in it, but it, erm, decayed. (SCNR)
 
8:07 PM
@FredOverflow typename std::remove_reference<T>::type, except for arrays where it's remove_extent, and for function references it turns then into pointers
 
@LucDanton For arrays, it's array to pointer decay. You forgot the pointer ;)
 
@FredOverflow Good catch
 
It seems std::decay is mostly useful with decltype...?
 
@sbi: I'd rather just have C++0x and C++11 be approved as synonyms
retagging one question isn't a big deal
 
With std::decay to write std::make_tuple all it takes is ideone.com/9GXbK
 
sbi
8:10 PM
@DeadMG There's no such thing as sibbling synonyms. No universal suffrage for tags. There's always only one tag beiong a synonym of another one. That will turn all occurances of that one tag into those of the other one.
 
So these days whenever I write a generic class that wraps a type I tend to provide a make_* helper that perfectly forwards
 
oh, is C++0x given as a synonym of C++11?
 
If you ever forget what tera or peta is, you can look at the C++ standard on page 603 :)
 
sbi
@DeadMG No, but I think it would make sense to make it that.
 
well
I would have thought that if X is a synonym of Y, then Y is a synonym of X
 
sbi
8:11 PM
@DeadMG Yep, but that's not how it works on SO.
 
@LucDanton That reminds me: I gotta learn variadic templates in depth.
Don't you just love types such as T&&...? :)
 
@FredOverflow For the record I made a mistake and forgot an ellipsis in the above
 
@sbi Really? LOL.
 
Also it's hard to abuse T&&
That's what I found amazing about it
Possibly auto&& is somewhat risky
 
auto is the best hing ever
 
8:14 PM
@LucDanton I could never get used to the term "ellipses". I just say "dot dot dot" :)
 
sbi
@FredOverflow Yes, it is a practical approach.
It wouldn't make much sense to replace all occurrances of tag A with tag B and all occurrances of B with A, after all.
 
@sbi Ah, so defining synonyms is a precursor to retagging?
 
@sbi hi
@DeadMG hi there!
 
hello
 
Hm, in mathematics, is "symmetric" a synonym of "commutative"?
 
8:17 PM
no
 
sbi
@FredOverflow I wouldn't exactly call it a "precursor". It's an automated way to retag, though. As such, it's probably younger than simple retagging.
 
Is symmetric a special case for two arguments?
 
no idea
 
can somebody tell me that after 1400 lines of visual c++ code
 
symmetric applies to shapes, commutative doesn't, even if they both apply to functions in the same way
 
sbi
8:18 PM
@echo9 (That "Hullo, @echo!" joke now loses more and more of its appeal.)
 
why does the compiler gives a warning such as "code not accessible.." line 1405..
 
Hello every one! I have finished Uni so can now bum around here some more :D
 
@DeadMG So if f(a, b) = f(b, a) for any a and b, does that mean that f is symmetric or commutative?
 
@echo9: Because you attempted to violate C++'s access control rules
 
@sbi a what?
 
sbi
8:18 PM
@echo9 Itz usually does so, because the code in line 1405 isn't accessibale.
 
(And please don't answer with "yes".)
 
@FredOverflow Commutative is (a op b) op c <=> a op (b op c) isn't it?
 
@FredO: I have no idea, but you sure can't call a square a commutative shape
 
but my program gets compiler and linked successfully
 
@LucDanton No, that's associative :)
 
8:19 PM
Associativity? I can't remember this stuff anymore !
 
sbi
@echo9 what a what??
 
@DeadMG I'm talking about functions only.
 
then I have no idea, never seen symmetry applied to functions
 
so is it really "unaccessible" to the compiler or is it just a compiler warning based on some flag
?
 
@LucDanton Well, it's important to have at least a basic understanding of these things when you overload operator== and operator< :)
 
8:20 PM
@echo9: It means you violated C++'s access control rules, it's nothing about the compiler specifically or the quantity of it
if you don't know what I'm talking about, then you need to read up on it
 
sbi
@echo9 Oh I now see. You don't understand the term "inaccessible".
 
@echo9 could it be that it is an if or switch such that it will never be executed?
 
uh...ok allright..but is it same for when i compile the code in Linux..?
 
> In the case of symmetric functions, the value of the output is invariant under permutations of variables.
Symmetry occurs not only in geometry, but also in other branches of mathematics. It is actually the same as invariance: the property that something does not change under a set of transformations. Two objects are symmetric to each other with respect to the invariant transformations if one object is obtained from the other by one of the transformations. It is an equivalence relation. In the case of symmetric functions, the value of the output is invariant under permutations of variables. These permutations form a group, the symmetric group. In the case of isometric transformations in Eucl...
 
@echo9: I told you that it's nothing about the compiler, what do you think?
 
sbi
8:21 PM
@DeadMG If it's a warning, and it says "code isn't accessible" (not identifier), then that usually means execution can never reach that code. (Sorry for yelling. CAPSLOCK.)
 
yeahh.. there is a switch in there a huge switch case :( n to my surprise it doesn't get executed properly!
 
@FredOverflow I plead guilty in that I always use an ordering so banal that I don't have to think too much about it (e.g. last time was a lexical ordering)
 
@echo9 then chances are, your logic is wrong
 
@LucDanton You mean lexicographical, right? ;)
 
@thecoshman you guessed that one absolutely right..
 
8:22 PM
@FredOverflow Yes; fumble
 
@echo9 the 'huge switch case' raised suspicion.
 
@LucDanton Oh wait, they seem to be synonyms...?
 
well.. i don't think so.. since that code is pretty much working as a production code.. although very few people have tested that on win
 
@thecoshman Any switch/case raises suspicions, at least for OO aficionados :)
 
@FredOverflow Let's claim 'lexical' is also about collation, but only because I wanted to say 'collation' today
 
8:23 PM
@echo9 'pretty much work', that's just another way of saying, it doesn't work
 
@thecoshman But it sounds better :)
 
there's nothing wrong with switch case of the right size
but once it reaches a certain size, there's a question about it
 
@thecoshman so will it be same i mean the code not accessible thingy in linux gcc/g++ too? what i really want to say is it compiles allright in win and nux but when i try it in win it simply refuses to match case some middle and end cases of that huge case
 
@FredOverflow how so? I don't often find my self using switch statements, but when I do, it seems the best way
 
@thecoshman :D hehe.. well am lazy
should i post it in here..? the code sample for my switch case..?
 
sbi
8:25 PM
@echo9 Lemme tell you this: I have been programming C++ for almost 20 years, and I have seen bugs sneaking passed compilers, testers, and customers for a decade, which you'd think any newbie would smell without even looking at the coe in question, just by it being on the HD.
 
@thecoshman just the switch case..?
 
@echo9 with out looking at the code, I can't really say much more then check, re-check and check yey again your logic is spot on
 
@thecoshman It doesn't use at least 3 different design patterns to be OO enough.
 
@thecoshman Many switch/cases can be replaced by subtype polymorphism. But I'm not an OO purist, don't ask me ;)
 
wait i'll just copy/paste that thing right away for you guys..
 
8:27 PM
@echo9 probably better of with a proper SO question, unless it is really quick. Maybe just your switch statement, along with what you think it should be doing
 
imo, one of the major reasons against subtype polymorphism is the relative cost of dynamic allocation
 
sbi
@echo9 NO!
May 10 at 14:25, by Martinho Fernandes
The act of isolating the problem into a simple example that reproduces it tends to keep my question asking rate on SO very low. It's a great debugging technique.
 
@echo9 If you're pasting code, use pastebin/ideone/whatever, thanks.
 
if you wrote a specialized allocator for it, it would be significantly less of a waste
 
sbi
@sbi That's a much better idea!
 
8:27 PM
@sbi You can detect errors just by smelling a harddrive? Is that where the term "code smell" comes from?
 
especially if the subtypes could be created by use of a template or something
 
yep i'll go with pastebin :)
 
@DeadMG Dynamic allocation is very cheap in modern managed languages.
 
C++ isn't managed
 
I know.
 
8:28 PM
besides, their initial allocations might be cheap, but you have to run that object every collection
 
C++ also isn't OO, so I don't try to fit everything into the OO model.
 
it is completely OO
 
It is not just OO. You are allowed to think non-OO thoughts in C++ ;)
 
sbi
@echo9 I certainly won't look at a switch statement with lines in the four digit number, not matter whether on pastebin or anyhwre else. Takes @Martinho's advice serious!
 
so are we all looking for to C++3X? the naughtiest C++ yet :D
 
sbi
8:29 PM
@FredOverflow Well, some bugs are so ridiculous, you'd think they could be smelled.
 
I know, but I don't see what that has to do with saying that it's not OO
because it completely does support OOP
 
@thecoshman I thought that would be C++69.
 
there you go :)
 
@CatPlusPlus I can't wait that long ¬_¬
 
You already said yourself that sometimes using templates leads to better solutions than using classic OO constructs.
 
8:30 PM
yeah, I know
but that doesn't mean that C++ isn't OOP, because it is, it's just also generic and etc etc
 
@thecoshman Don't worry, they'll invent time travel by then.
 
@echo9: That is quite possibly some of the worst C++ I've ever seen
 
well i suppose you guys must from US ..but am from India and its 2AM int he morning..so I am thinking to go to bed
 
oh god! switches in switches :S
 
Well, since there is no agreed-upon definition of what OO really is, it's hard to say whether C++ is OO or not. I'm sure Smalltalkers would say that C++ lacks too many things to be considered OO.
 
8:31 PM
@CatPlusPlus I argue that if it is going to be invented, then it was always invented
 
@thecoshman yep! thats right.. so is it this thingy thats keeping my win based visual studio to just skip over.. or will it behave the same in nux too ? (sorry haven't tested it in nux yet :( )
 
@thecoshman Okay, we'll find out they invented time travel by then.
 
We were talking about code smells, and then I see strcpy everywhere
 
@DeadMG I stopped reading at strcpy.
 
@FredO: Yeah, that's what I did too
 
8:32 PM
@echo9 I would re-work it so that you can just use one switch statement, rather then having a major and minor
 
and you sure as hell don't need subtype polymorphism to say, create an array of strings and just return from that
you don't even need that
 
I see break indented wrong, and that's killing me.
 
@DeadMG yea..I got that one from you the very first day you solved my question ..
 
@echo9 it should work the same compile for win or *nux
 
@echo9: I solve a lot of questions, you will have to be more specific
 
8:33 PM
@DeadMG "worst C++ code.. :D " ahh..never mind
 
sbi
@CatPlusPlus "Them" incenting time travel "by then" doesn't help me a bit. All that would allow is my descendants showing up now and exlaining to my why I fucked up big time in their past (which is my present). I really fail to see how this could be an advantage for me.
 
@echo9 It doesn't even need switch.
 
@DeadMG Is that addressed to me? Please explain in detail what you mean.
 
@thecoshman actually its a much smaller part from a quite lengthy file.. I would say..
 
@echo9 Have you considered refactoring this in one or two functions that returns a container of strings (error messages?) that you append to m_statMsg?
 
8:34 PM
Or maybe just one.
 
@FredO: We or quite possibly just someone, my memory is a little vague, was discussing replacing switch/case with polymorphism because it doesn't use enough design patterns, or something
 
sbi
@DeadMG "I solve a lot of questions." What a humble statement.
 
And why on Earth are you using libc string routines in C++.
 
@LucDanton well not exactly.. din't had much time for that :(
 
but this particular switch/case is just an array or array of arrays of strings
ah, cack
 
8:35 PM
@sbi as thinking that too :P
 
@DeadMG Ah, I didn't really look at the code.
BTW "not enough design patterns, or something" is really funny :)
 
@sbi: It doesn't take many for you to not remember every questioner and answer offhand
 
This screams for some (int, int) -> string mapping doesn't it
 
laughing my arse off here
 
@FredOverflow What's the date of this C++0x overview with Stroustrup u posted above?
 
sbi
8:36 PM
@thecoshman Ha! ood cause for another humble statement: Great minds think alike!
 
@DeadMG did a project for uni that had an array of array of array of array of array of Index buffers :P
 
yo, srsly?
 
@thecoshman Five-star programming?
 
why?
 
@all its just the part which will be taking care of any exceptions occurred during data transfer, socket, connection creation, address bind etc like stuff
 
sbi
8:36 PM
@DeadMG No, it doesn't take many for me, but I'm old, and you are young! (@wilhelmtell, do you copy?)
 
@Nils Several years ago, when concepts were still part of C++0x. 2008, I would guess.
 
@sbi: 1500 is more than enough for me
 
ok
 
sbi
@thecoshman I know a piece of code (likely to be on your HD), that has four nested std::map.
 
@FredOverflow well it's still interesting
 
8:37 PM
@LucDanton Multidimensional arrays and nested pointers are not the same ;)
 
sbi
@DeadMG 1500 ought to be enough for anybody!
 
@DeadMG most of them where arrays of length 2, so it meant I could use a boolean to access the Index buffer I was after
 
@sbi: Where's that?#
 
But funny nonetheless!
 
@sbi go on...
 
8:38 PM
@sbi You're missing a closing paren!
 
@thecoshman: I don't see what booleans you would use
 
sbi
@thecoshman There's nothing more to tell for me. (I did sing an NDA.)
 
@FredOverflow Five-index programming doesn't have the same ring to it; when you could have five-star programming just some decay (and a lot of gray area) away!
 
@DeadMG it was along the lines of indexBuffers[hasleftlink][hasrightlink][hasfrontlink][hasbacklink][levelofdetail­]
 
@Nils Are you watching it right now? Yeah, it's extremely interesting to see and hear the inventor of C++ talk about the development of the language. I have watched that video at least half a dozen times. (Sounds better than 6 times, doesn't it?)
 
8:39 PM
@echo9 You can replace that with arrays of strings.
 
@CatPlusPlus arrays of strings..?
@CatPlusPlus n hows that?
@CatPlusPlus *possible..?
 
@thecoshman: which links?
 
@echo9 std::string myStrings[5]; // array of five std::string objects
 
sbi
2 days ago, by sbi
@Raze Yes, but what I was trying to say was that, while most programmers are finicky, C++ programmers are anally so. :)
 
std::string foo[10];               // good old C++98
std::array<std::string, 10> bar;   // shiny new C++11
 
8:41 PM
@DeadMG it is for a terrain level of detail. the boolean values where for if a section of tile needs to merge level of detail down to a section next to it.
 
ah
 
@thecoshman An array with bool as index? Cool :)
 
@FredOverflow it made sense to me :D glad you like it
 
sbi
OMG! Of course, I signed the NDA. (I never sing NDAs.)
 
why not just rotate it to make the link match the side you need, and have like, 1,2, 3, 4 sides
 
8:43 PM
@thecoshman so are you suggesting me something like "std::string m_statMsg[5]" n then storing the message independently in each of these arrays..?
 
yes
 
@DeadMG if the tile needs to lower the level of detail, then it will use a special linking index buffer, these link strips need to be different for each side, as they needs to use the right vertices for that side. If the section did not need to lower level of detail down to a section next to it, then it would use the normal LoD for that section of terrain
 
hm
in what game?
 
allright then guys.. I gotta go now
off to bed
 
or rather
what style of game?
 
8:45 PM
@echo9 I believe so, but I don't know exactly what your code is doing. My main concern would be your epicly long logic
 
ciao~
 
@echo9 u should go out and drink :)
 
@echo9 @echo off
 
it's my understanding that normally, each entity is LoD'd independently
 
@DeadMG it was for a tech demo for a sort RTS game. It was for LoD for the terrain
 
8:46 PM
@thecoshman heh.. the logic.. omg dont taalk about the logic n stuff; I have been working for 2 solid months on this project
 
LoD = Lord Of Destruction, the Diablo 2 add-on? :)
 
@FredOverflow hah :P overflow -1
 
unless I'm mistaken, the terrain's distance is usually fixed for RTS games
even Supreme Commander didn't LoD the terrain
and there you could zoom out to see the whole map and more at once
 
@Nils thanks for the tip ;) will try that too but sometime later..
 
so a building or player model, yes you can just LoD when ever you want. Terrain is both near and far from the player
 
8:47 PM
true
but RTS terrain tends to be relatively simplistic, and more importantly, there's only ever one instance of the terrain
 
Wow, you guys do real programming in C++ instead of abstract template wankery? Kudos :)
5
 
whereas player models, for example, are everywhere
lol
 
@DeadMG like I said, tech demo. So it was about showing how the LoD can change when you are zoomed right in and move further away and it reduces. It also was only updating the LoD on key press so that you could see how the LoD has been applied over the terrain
 
ah
 
@DeadMG yes, but if you have a large map, you want to be able to see it rather detailed when you are close to it. But that level of detail dose not need to be applied to the entire map.
 
8:49 PM
well
 
@thecoshman which tech demo?
 
You will certainly want to cull regions of terrain that you are not even looking at
 
from experience playing a very large RTS with very large maps, there's not that much reason to zoom in
frustrum culling is something different
 
@Nils it was group course work for uni
 
ah u study together?
 
8:50 PM
what, us? no
 
I also did a tech-demo once. It was a spinning triangle with linearly interpolated colors :)
(Pure software rendering.)
 
@DeadMG but if you are going to let the player zoom in, you want to let them see a decent looking bit of terrain. Besides, the technique could be applied to say an FPS game
 
lol
@thecoshman: But you're wasting time and effort dealing with the terrain, when it's perhaps the least relevant and detailed part of an RTS game
 
@FredOverflow that's the interesting part, software rendering... madun
 
once you discern it's basic shape, it's really not that important
 
8:51 PM
@thecoshman Do you get sudden LoD changes when you zoom in? Or are the levels somehow interpolated?
 
@FredO: That's where hardware tesselation comes in
it's famously known as "model popping", where a low-detail is suddenly replaced with a high-detail
if you had to render or deal with the high-detail, it would defeat the purpose of LoD
but hardware tesselation solves that problem
how it does that, I don't recall, but I do know that it's intended to solve that problem
 
@FredOverflow Sadly, I never got time to implement a really good function for applying the LoD, but in theory, if balanced right, you would not get a pop when the LoD increases, and there where about 6, so it would slowly get better as you come closer to a point on th emap
@DeadMG its more the other way around using tessellation shaders
 
@thecoshman Also, it was VGA DOS stuff. You know: mov ax, 13h; int 10h; mov ax, 0a000h; mov es, ax; :)
 
with tessellation shaders, you would pass very big triangles to the graphics hardware to be rendered, and let the shader add in extra geomotry, usualy using a height map texture for something like terrain
 
@DeadMG Hardware tesselation is a new kind of shader, right? Geometry shader or something?
 
8:55 PM
though you might use it to for cobbles on the road, or a brick wall
 
it's three new shaders
 
@DeadMG Whoa, so a total of five then?
 
no, seven
 
...And I thought having to program two different kinds of shaders was already complicated :)
 
DX9 (vertex, pixel), DX10(geometry), DX11(hull/tesselator/domain, Compute)
vertex/pixel isn't complicated
 
8:56 PM
@FredOverflow it's mad trying to think about using CPU bound code, along with vertex and pixel shaders
what are hull and domain shaders?
 
I'm not completely sure
they're part of the tesselation stage in general
 
Damn, the Bjarne video is in stereo, but the right channel is mute. Is there any way to "dupe" the left channel on the right?
 
I've not been allowed to player with DirectX 11 thanks to uni :(
 
I think that the hull shader inputs to the tesselator, then the domain shader handles the outputs
 
@FredOverflow yes
 
8:58 PM
Oh wait, VLC has built-in support for that, awesome! audio/audio channels/left
 
maybe the tessellator is implemented in hardware and it's not actually a shader
yeah
 
@DeadMG That's what Nvidia was advertising IIRC
 
tessellator is fixed function, not a shader
so it's just six shaders
 
I am fairly sure that a lot of the 'new' DX shaders are things that openGL has had for a while. MS just seem to have ranted about some new names for these things...
 
@DeadMG Are those new DX11 shaders also available in the OpenGL shading language?
 
8:59 PM
@thecoshman: I think that OGL4 has hardware tesselation, or something like that
 

« first day (210 days earlier)      last day (4753 days later) »