SERVING THE QUANTITATIVE FINANCE COMMUNITY

Cuchulainn
Posts: 60835
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Modern & Effective C++ design ideas

QuoteOriginally posted by: Traden4Alpharotate(Composite& c, double angle) illustrates one of the challenges of apply functions to elements of a container. Should rotate() operate on the assemblage or only on the elements? And if it operates on the assemblage, the rotate() must iterate once over the container to assess the assembly and then iterate a second time to do the required rotate() and move() to affect the composite rotation.In other words, how do we know if a given composite is just a set of independent objects with no relationships between the objects versus a set of dependent objects with some relationships that should be preserved during rotate()?Using subtype polymorphism this problesm is solved using Composite objects and Composite visitors. I used it for motion simulation of assemblies. Very easy.Independent objects don't occur too often in CAD.I digress.Goal: Same in C++ 11.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60835
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Modern & Effective C++ design ideas

QuoteOriginally posted by: outrunCuch, can your CAD move rotate the floor instead of all the components of the composite? When I was a student we hade frames and rotation/translation matrices at each level of the hierarchy. The location of an object after modification was then computed as the composite of all transforms on all levels.Yes, no problem.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60835
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Modern & Effective C++ design ideas

QuoteOriginally posted by: outrunScheltema (Amsterdam's glorious bookstore that almost went bankrupt recently) had *1* C++ book!!... And a weird one too, a tautological audience IMO, "C++ for the impatient". ... Right, ...Koningsplein.And how many (unsellable) maths books.Better to go to Gollem! I used to know it as Holkema-Scheltema.
Last edited by Cuchulainn on May 25th, 2014, 10:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### Modern & Effective C++ design ideas

outrun: yeah, function objects occurred to me as well, but the issue is that we no longer have direct/OOTB support for free-standing functions.Of course, one could have the additional requirement for the client-code to have a wrapper/adaptor -- for instance, this is what Boost.Phoenix does:http://www.boost.org/doc/libs/release/l ... .htmlStill, it would be more convenient (from the client-code p.o.v.) not to have to have this requirement.If the need arises, though, it's worth noting that we no longer need macros -- nor even hand-written function objects -- if we use C++14 generic lambdas.Check this out:http://cpptruths.blogspot.com/2014/03/f ... t-1.htmlIn particular, consider identityf, applyf , curry, partial, bind.For instance, note how partial(addFour,1,2)(3,4) takes addFour (which itself is generic!) as an argument.// What's important here is that there's no need to say addFour<int> or the like.So, at least this is something that is (hopefully) going to become less onerous with C++14; and, in the meantime, perhaps we can have a "work-in-progress" draft code using function objects. Also interesting:http://learnmeahaskell.blogspot.com/201 ... tions.html
Last edited by Polter on May 25th, 2014, 10:00 pm, edited 1 time in total.

Cuchulainn
Posts: 60835
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Modern & Effective C++ design ideas

Keep plugging!James Dyson, famously created 5,127 prototypes of his first machine, the vacuum cleaner, in a workshop behind his house, before developing one that he considered worked perfectly, the DC01.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 ABOUT WILMOTT

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...

 JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...

GZIP: On