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 33,158 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: How to implement std::tuple's someti   
   03 Aug 13 10:44:47   
   
   From: daniel.kruegler@googlemail.com   
      
   Am 02.08.2013 22:47, schrieb Daniel Krügler:   
   > If you only want to impose constraint upon the size, this can be solved   
   > like this:   
   >   
   >   template      typename std::enable_if::value == 2,   
   > bool>::type = false   
   >   >   
   >   my_tuple(const std::pair&);   
      
   Oops, the heat has burned my brain: The suggested approach doesn't work   
   as promised, because I inverted the roles of type-dependency here. We   
   need to ensure that the member template uses type-dependent expressions   
   within the sfinae-test, but this doesn't happen here: Given an   
   instantiation of my_tuple the expression   
   std::tuple_size::value is not dependent on U1 and U2 (that is   
   needed here), so lets fix that by using my previously suggested   
   pack_size template as follows:   
      
     template(),   
   bool>::type = false   
     >   
     my_tuple(const std::pair&);   
      
   You can use std::tuple_size::value instead of   
   sizeof...(Types), but it is not necessary.   
      
   My last example of my previous reply regarding implied size-checks   
   should be correct, though, because the test-expression contains the   
   type-dependency of the member-template.   
      
   I apologize for my initial misleading response.   
      
   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