- void* address of most derived type - 5 Updates
- Is template metaprogramming allowed by the standard? - 2 Updates
- Is template metaprogramming allowed by the standard? - 1 Update
"Norman J. Goldstein" <normvcr@telus.net>: Apr 10 12:28PM -0700 On 04/10/2015 12:06 PM, Paavo Helde wrote: > deficiences via multiple derivation and dynamic_casting between my and MFC > class hierarchy trees). Worked pretty well actually, at least when compared > to the rest of the MFC mess. I will be using the void* cast to ensure that a shared_ptr is written to disk only once. So, the disk IO will dominate the dynamic casts. The conversations in this thread were quite helpful. Regards, Norm |
Mr Flibble <flibble@i42.co.uk>: Apr 10 09:16PM +0100 On 10/04/2015 20:28, Norman J. Goldstein wrote: > is written to disk only once. So, the disk IO will dominate the dynamic > casts. > The conversations in this thread were quite helpful. It is very rare to avoid dynamic_cast for performance reasons, it is more common to avoid dynamic_cast because using it is a code/design smell: consider refactoring your design so you can use virtual functions instead sausages. /Flibble |
"Norman J. Goldstein" <normvcr@telus.net>: Apr 10 01:58PM -0700 On 04/10/2015 01:16 PM, Mr Flibble wrote: > more common to avoid dynamic_cast because using it is a code/design > smell: consider refactoring your design so you can use virtual functions > instead sausages. The problem with virtual functions is that you need to implement them, and that precludes using classes that you either cannot, or do not want, to modify. I suppose the two approaches can be combined: If the virtual method exists, then use it; otherwise, do the dynamic cast. |
Mr Flibble <flibble@i42.co.uk>: Apr 10 10:09PM +0100 On 10/04/2015 21:58, Norman J. Goldstein wrote: > and that precludes using classes that you either cannot, or do not want, > to modify. I suppose the two approaches can be combined: If the > virtual method exists, then use it; otherwise, do the dynamic cast. If you have classes that you cannot modify or do not want to modify yet require modification in order to correct a shite design then you need to have a word with yourself. I have very few dynamic_cast in my codebase and none at all in my non-library code sausages. /Flibble |
Ian Collins <ian-news@hotmail.com>: Apr 11 11:16AM +1200 Norman J. Goldstein wrote: > and that precludes using classes that you either cannot, or do not want, > to modify. I suppose the two approaches can be combined: If the > virtual method exists, then use it; otherwise, do the dynamic cast. That doesn't make any sense. The only virtual functions you need to implement in a derived class are pure virtual functions. To use a dynamic cast the types have to be polymorphic so they will already have at least one virtual function. -- Ian Collins |
Peter <pilarp@poczta.onet.pl>: Apr 10 03:22PM -0700 It's going to be a very general question, but here it goes: is template metaprogramming a serious programming technique, used in real-life code? Is there anything in C++ standard that guarantees its validity and/or portability (at least to some extent) or is template metaprogramming merely a curiosity, an unexpected side effect of adding templates to language definition and everything about it is either undefined or implementation defined? |
Robert Wessel <robertwessel2@yahoo.com>: Apr 10 06:15PM -0500 On Fri, 10 Apr 2015 15:22:18 -0700 (PDT), Peter >It's going to be a very general question, but here it goes: is template metaprogramming a serious programming technique, used in real-life code? Is there anything in C++ standard that guarantees its validity and/or portability (at least to some extent) or is template metaprogramming merely a curiosity, an unexpected side effect of adding templates to language definition and everything about it is either undefined or implementation defined? There's no real boundary between using templates as the sort-of soupped up macro facility it was intended for, and for meta-programming. It's just that templates are a crappy programming language (as a direct result as not having be designed for that purpose). But the techniques used are not new or uncommon. More than a bit of CS involves doing things with recursion instead of iteration, for example, and that, plus a bit of string hackery, gets you to doing the same with templates. |
ram@zedat.fu-berlin.de (Stefan Ram): Apr 10 10:29PM >is template metaprogramming a serious programming technique, >used in real-life code? »Serious« and »real-life« are not technical terms. >Is there anything in C++ standard that guarantees its >validity and/or portability (at least to some extent) Yes. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment