Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,158 of 33,346    |
|    =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to asif.lse    |
|    Re: Maintaining stack semantics but usin    |
|    18 Apr 12 09:52:11    |
      1b4239cb       From: daniel.kruegler@googlemail.com              On 2012-04-18 13:57, asif.lse wrote:       > I want to specify only ONE return type in this function.              What do you precisely mean by "this" function?              > I suspect I could auto here and use decltype to declare a pointer to       > the returned type so that I could assign that pointer/ref to a       > pointer/ref to an abstract class for polymorphic access. I haven't       > read up much on these new C++ features but could somebody help me       > here? I want to use stack variables and yet want to execute       > polymorphic code. The problem is that I have to specify the concrete       > class name and return type. So, apparently, there is no       > polymorphism. I am just thinking off the top of my head but I feel       > that this is very doable. Can I use templates here?              You should think about keeping the polymorphic behaviour *within* the       return type. std::shared_ptr is similar, because the dynamic       polymorphism is still provided by the contained object. Think of it as       some form of adapter technique. Other examples with similar       characteristics are std::function: The function call expression is       potentially polymorphic, depending on the provided callable object.              HTH & Greetings from Bremen,              Daniel Krügler                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca