Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 27th, 2014, 9:33 am

QuoteDyson is sooo full of himself. It's just a vacuum cleaner, not a fusion reactor. Yeah, full of hot air (gebakken lucht). Quoteyou're not allowed to pass a function template as argument to a templateIndeed.Because a function is not a type?
Last edited by Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 27th, 2014, 11:03 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteDyson is sooo full of himself. It's just a vacuum cleaner, not a fusion reactor. Yeah, full of hot air (gebakken lucht).Yes, 12 tornado twisters of hot airQuoteQuoteyou're not allowed to pass a function template as argument to a templateIndeed.Because a function is not a type?Nice! That's probably it! It might also have to do with the fact that functions support overloading, ..which resulted in the requirement that template functions needed argument type deduction,.. which made things too complicated to take it to the next level? Maybe they thought "we can safely assumethat there is no need for template function template template parameters." I agree. For types TTP is OK but the problem I had was getting the object "into" as the argument of the function.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 27th, 2014, 12:53 pm

QuoteOriginally 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?Is MACRO compile-time?
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 27th, 2014, 2:26 pm

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally 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?Is MACRO compile-time?It's PRE-compile-time First the macros are evaluated by the pre-processor and that generates text files. Once that's done the compiler will start to process those generates text files and read them as C++ code. Eg if you say "#define x 42" then all "x" ASCII chart in your source file will be replace with the two ASCII chars "42".http://stackoverflow.com/questions/6527 ... ossHarmful, very.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 27th, 2014, 2:47 pm

Check this out. 1. non-virtual/non-virtual hereother options2. V/V3. V/NV4. NV/V
Last edited by Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 27th, 2014, 3:30 pm

QuoteOriginally 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?QuoteI 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?
Last edited by Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

Modern & Effective C++ design ideas

May 27th, 2014, 4:07 pm

QuoteOriginally 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 perhaps generic lambdas (BTW, it's plural, not possessive, English != Dutch :]) as in "But What About Plain Old Functions?" -- beautifully named `_L` converts functions to lambdas:http://learnmeahaskell.blogspot.com/201 ... s.htmlEDIT: no, this seems to fail, too; also with C++17(?)'s `auto add1(auto x)` -- with the analogous error to the one for `template <typename T> T add1(T x)` (unresolved overloaded function type) :-/
Last edited by Polter on May 26th, 2014, 10:00 pm, edited 1 time in total.