SERVING THE QUANTITATIVE FINANCE COMMUNITY

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

### Modern & Effective C++ design ideas

QuoteOriginally posted by: PolterQuoteOriginally posted by: outrunThe only option is a MACRO IMO, ..like Polter pointed uit with Boost.Phoenix. I don't see how we can do it with generalized lambda's eitherany ideas?Either macros or generic lambdas (BTW, it's plural, not possessive, English != Dutch :]) -- see "But What About Plain Old Functions?" -- beautifully named _L converts functions to lambdas:http://learnmeahaskell.blogspot.com/201 ... ns.htmlThe use of ' in Dutch plural (meervoud) words is an interesting one. If you remove the ' it becomes a different word , so be it. See OT thread "Random photo's" ! They need an apostrophe to keep their vowels long. So, in Dutch the ' is plural but it does look like a possessive form. Does the plural of lambda exist? Should it not be lambdes?
Last edited by Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.

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

### Modern & Effective C++ design ideas

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunPivot point could be an argument too, right? That would allow you to make the member function static.Maybe. Why do you want a static function?Ai, I think I misunderstood "pivot point". If we have a circle with radius 1 at {x,y} coordinates {10,1} (at the right on the x-axis) then we can do two rotations. We can rotate it 90deg ccw while keeping the circle's center at {10,1} -which wouldn't change a thing-, or we can rotate it 90deg ccw around the point {5,5} which would move the circle center to {9,10}. I thought the pivot-point was the point around which you would do the rotation. Together with the angle it would determine how to move the circle to a new location. You were calling the circle center {10,1} the pivot point, that's a property of the circle instance.Making a function static is telling the compiler that the function will do nothing with the data members of the object, not even look at them. It then becomes more like "normal function". Making a member function const tells the compiler that is won't change the objects data members, but it might read them. Telling the compiler what the function can do is similar to making thing const, private etc. Also, since static function don't do anything with data member, the compiler is not going to bother to pass a pointer to an object datameters to the function. Another thing I like is that you van use static member functions without having to instantiate an class.QuoteQuoteI think you can make it easier extendible by changing Rotate::rotate into a template member function. That way you can add new specializations for new shape types without having to modify the source fileGood idea!! QuoteEg you can then add this specialization somewhere in the new pentagon.hpp header filetemplate<>void Rotate::rotate(Pentagon& p5) { ... };This is a free function?How can we formally introduce pivot point to Pentagon? Does template specialisation ensure this automagically?This is either a regular member function, or a static member function.I think making as few assumptions as possible..Rotation matrix Gotta get this into the design.
Last edited by Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.

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

### Modern & Effective C++ design ideas

Sir Roger Casement was hung, drawn and 1/4ed and thrown into a lime pit (he was dead at the time) because of a misplaced komma.

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

### Modern & Effective C++ design ideas

QuoteOriginally posted by: outrunThe heterogeneous container should work like this right?1. Have you defined the structure of this container, precisely?2. Your drivers like rotate() seem to be stateless; this is an issue (where do you put the rotation matrix for Circle, Point). I might have missed the answer. 3. We need heterogeneous drivers as well (e.g. animator := (rotate | mirror | translate)* (even nested/recursive animators at run-time).
Last edited by Cuchulainn on May 27th, 2014, 10:00 pm, edited 1 time in total.

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

### Modern & Effective C++ design ideas

QuoteOriginally posted by: outrun1. Ideally it should be a standard container (concept)2. The drivers have arguments:rotate(shape, angle);rotate(shape, center, angle);translate(shape, dx, dy);mirrorx(shape);3. Have to think about that! We have a heterogenous invoke now, a different approach.1. Ok. But can the element can be base class pointers or not?? i.e. std::list<Shape*> yes or no?2. hmm, a lot of maintenance. In my CAD I have about 20-30 different kinds of drivers.

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

### Modern & Effective C++ design ideas

Quote[...]use class templates when I mean class templates and template classes when I mean template classes. That stuck, even though I still need to look it up sometimes.These are confusing terms (indeed). I have not idea. Even Wiki is having difficulty.Josuttis et Vandeoorde .class template == parametrised class (family of classes). template class --> NOT DEFINED. function template == family of functions.. Personally, I prefer 'template class'
Last edited by Cuchulainn on May 27th, 2014, 10:00 pm, edited 1 time in total.

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