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,666 of 33,346   
   Cassio Neri to Zhihao Yuan   
   Re: How to write an is_nothrow_swapable<   
   21 Nov 12 15:36:58   
   
   From: cassio.neri@googlemail.com   
      
   On Friday, November 16, 2012 9:20:09 AM UTC, Zhihao Yuan wrote:   
      
   > However, I want it to be able to work on just a type, to work as an   
   > integral_constant.  Is that doable?  Comments on how to implement an   
   > is_swapable are also welcome.  Thanks.   
      
   Once I had the same need and implemented as below. I'm sure it's far from   
   perfect but it might serve as a starting point. I  also welcome comments on   
   my implementation.   
      
   //    
   namespace details {   
   using std::swap;   
      
   template    
   struct is_nothrow_swappable : public std::false_type {   
   };   
      
   template    
   struct is_nothrow_swappable(),std::declval()))>::type> : public std::true_type   
   {   
   };   
      
   }   
      
   using details::is_nothrow_swappable;   
      
   //    
      
   To be honest, I don't remember why I considered two template parameter types   
   T and U :-(   
      
   Cheers,   
   Cassio.   
      
      
   --   
         [ 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