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,587 of 33,346   
   Marc to All   
   Re: why std::vector&& is not a univer   
   10 Oct 12 01:46:52   
   
   From: marc.glisse@googlemail.com   
      
   Daniel Krügler  wrote:   
      
   > On 2012-10-09 15:16, Gennadiy Rozental wrote:   
   >> On Tuesday, October 9, 2012 12:30:03 AM UTC-4, Daniel Krügler wrote:   
   >>> Am 09.10.2012 00:48, schrieb Gennadiy Rozental:   
   >>>> Any workarounds?   
   >>> The usual technique is to specify a function of the form T&& and to   
   >>> constrain it accordingly. E.g.   
   >>> #include    
   >>> #include    
   >>   
   >>> template   
   >>> struct is_vector : std::false_type {};   
   >>> template   
   >>> struct is_vector> : std::true_type {};   
   >>   
   >> While we on the subject, why doesn't standard type traits provide   
   >> this?   
   >   
   > I don't think that this trait should be standardized, because it is   
   > neither very complicated to write, nor do I see any general pattern in   
   > it.   
      
   I guess this version is very slightly more general:   
      
   templateclass U>   
   struct is:std::false_type{};   
      
   templateclass U>   
   struct is,U>:std::true_type{};   
      
   static_assert(is,std::vector>::value,"error");   
   static_assert(!is,std::vector>::value,"error");   
      
   I agree with your post, I just wanted to mention this because I find it   
   nice that variadic templates allow it. It gets harder if we want 'is' to   
   act like is_same for non-template parameters U though :-(   
      
      
   --   
         [ 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