home bbs files messages ]

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,778 of 33,346   
   ranisharoni75@googlemail.com to All   
   std::function using std::forward   
   06 Jan 13 03:39:58   
   
   { Reformatted; please limit your lines to 70 characters -mod }   
      
   Hi,   
      
   I was wondering about the usage std::forward in the std::function   
   underlying invoke operation:   
   20.8.11.2.4 – operator(A… a) – INVOKE(f, std::forward(a)…, R)   
      
   Will this be equivalent to simply using - INVOKE(f,static_cast(a)…,   
   R)?   
   This will mainly save annoying step-into std::forward during   
   debugging.   
      
   For example std::function:   
      int operator(int a, int b)   
        { return invoke-me(forward(a), forward(b))   
   vs.   
      int operator(int a, int b)   
        { return invoke-me(static_cast(a), static_cast(b))   
      
   Here is my analysis of std::forward vs. static_cast in the   
   context of std::function invocation:   
      
   1) A = T& -> std::forward == std::forward returning T&&& hence   
   T& == static_cast = static_cast   
   2) A = T&& -> std::forward == std::forward returning T&&&&   
   hence T&& == static_cast = = static_cast   
   3) A = T -> std::forward == std::forward returning T&& ==   
   static_cast = static_cast   
      
   Altogether std::forward is equivalent to static_cast in the   
   above (I know that this is not true in general, e.g. make_shared).  Am   
   I missing something?   
      
   Thanks,   
   Rani   
      
      
   --   
         [ 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