« first day (644 days earlier)      last day (2209 days later) » 

5:01 AM
Do you guys put in the name of the arguments in function declarations in header files?
e.g. public: int MyAddFunction(int a, int b) const;
Or just the types, e.g. public: int MyAddFunction(int, int) const;
 
 
2 hours later…
6:34 AM
@nobism names
@nobism I do what ReSharper C++ tells me to do
 
 
1 hour later…
7:50 AM
@nobism The prototype in that case is the only thing the compiler is interested in but anyway, I take the identifiers also in the header files. Its just how I learned to code in c++. stackoverflow.com/questions/7891526/…
 
8:36 AM
I have a GroupNode, TransformNode, CameraNode and a GeometryNode as concrete Nodetypes of my scenegraph. I need the possibility to get the global position from an node independent from traversing the scenegraph. Or more
precise, the transformation matrix at that stage. Would be an approach to implement an backtrack functionality for each nodetype ?
 
 
2 hours later…
10:33 AM
To show my inheritance hierarchy. The concrete manifestations needs these backtrack functionality. It multiplies the transformation matrices up while it running back to the root. Only the transformnode has a transformation matrix as member.
the backtrack would be in all the same except in the transformnode, there it multiplies its own transformation matrix also up.
A other approach would be to have these backtrack method as part of my rootnode. There i hand over the particular node as argument / startpoint for backtracking.
 
 
3 hours later…
Ron
1:20 PM
Should I prefer typedefs / using for verbose data members names or not? Like in this example.
I actually lean towards staying with the generic names. Is there a rule of thumb to be followed? When data member length is too much?
 
1:42 PM
Hmm dont know how to handle this...maybe throwing an exception ? coliru.stacked-crooked.com/a/35e6d88c28e0a918
 
@nobism Names unless it's a bincompat legacy parameter that I can't nuke.
 
 
1 hour later…
JKS
3:03 PM
Hello, how do I avoid this kind of copy-paste?
https://pastebin.com/im2C0b9J
Some bugfixes:
https://pastebin.com/jbhL5Rg3
 
with only one duplication I don't think it's really warranted
 
JKS
how do i put code here?
` Rational operator + (const Rational & rhs){ `
` Rational lhs = *this; `
` lhs += rhs; `
` return lhs; `
` }`
it's essentially the same for every operator
 
3:25 PM
but it's not enough that it's worth doing the macro magic required
all that will do is obfuscate the code
 
JKS
well macro solution is obvious
doesn't new C++ have any fireworks that may be a bit better?
 
What's the difference b/w using placement new operator and manually calling the constructor?
 
@Yashas The main difference is that placement new is something you can actually do. Ctors don't have names, so you can't call them directly.
 
3:43 PM
@JerryCoffin cpp.sh/5wois
 
@Yashas the second one constructs a temporary and uses the implictly generated copy constructor to copy into the prior
 
@Yashas Yes, and?
 
user image
3
if you hadn't declared a destructor it would have moved it in
 
nvm
 
buuut you did
Also never call a destructor explictly unless you've done placement new
because otherwise you create what's lovingly called undefined behavior!
 
3:55 PM
@Mgetz Well...usually. You can manage to do it without getting into UB--you just have code that's hard to use correctly, and easy to break (e.g., a smart pointer will break the code more often than not).
 
@JerryCoffin true they could have done a placement new on the allocated memory after calling the destructor.
 
@Mgetz Also possible to do it on memory allocated from the free store, so there won't be any attempt at automatically destroying the object when it goes out of scope. All going in exactly the opposite direction of where you'd hope to go though...
 
Agreed, normally the only things that have to do that sort of work are containers like std::vector
 
@Mgetz Yeah--as long as you keep it all hidden inside the container, it's not too terrible. Exposing it to the world though...eeewww, nasty!
 
a good object shouldn't need user code to placement new and destruct
 
4:43 PM
@ratchetfreak To be more complete: a good object should provide services that are meaningful in the domain of the problem you're trying to solve in a way that's meaningful to your target audience. The only way placement new and explicit destruction could fit would be if your target was heavy-duty C++ developers (though I could, possibly, see some sort of helper object for people writing containers that would still require them to deal with placement new and explicit destruction).
 
@JerryCoffin pretty sure we call that helper an allocator
 
@Mgetz That's one, but I can sort of imagine there being room for others. For example, though it doesn't really fit with the standard containers, I can imagine something like tree-based containers that use a strategy object to handle the tree-balancing, so we might have one balancer to do AVL, and another to do red-black. Such a balancer might work with nodes that have data emplaced into them using placement new, and destroyed with explicit dtor calls.
 
@JerryCoffin so using std::red_black_tree = std::tree<allocator, std::red_black_balancer>; ?
 
@Mgetz Something on that general order, anyway. I haven't really tried to think it through in complete detail though.
 

« first day (644 days earlier)      last day (2209 days later) »