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 31,685 of 33,346   
   =?ISO-8859-2?Q?Daniel_Kr=FCgler?= to All   
   Re: How to conditionally disable a copy    
   23 Nov 11 14:40:58   
   
   9829520d   
   From: daniel.kruegler@googlemail.com   
      
   On 2011-11-23 17:07, SG wrote:   
   > I wonder how std::vector is supposed to handle this. As far as I know,   
   > you are allowed to define members which cannot be instantiated as long   
   > as you don't try to instantiate them.   
      
   Yes for the second part. Does this answer your first question? Otherwise   
   I'm not sure what you exactly mean in regard to std::vector.   
      
   > But I guess this will interact   
   > badly with the copy/move-related traits in  unless you   
   > specialize them.   
      
   User-code shall not specialize any of the type_traits except for some   
   rare exceptions like std::common_type, see [meta.type.synop] p1:   
      
   "The behavior of a program that adds specializations for any of the   
   class templates defined in this subclause is undefined unless otherwise   
   specified."   
      
   > IMHO, C++ desperately needs a "requires" that's not only a native   
   > enable_if replacement but can also enable/disable non-template members   
   > of class templates. I'd even be happy about a requires-clause which   
   > only takes a compile-time boolean and does not involve "modular type   
   > checking".   
      
   In current C++11 this is possible for all members except for the special   
   members thanks to default template parameters.   
      
   Even in concept-C++0x it was not possible to constrain special member   
   functions, but I would consider this as an important requirement for a   
   new concept C++ revision.   
      
   > Until we get a "requires" clause, I'd try this:   
   > - simply remove the requires clause and rely on users not   
   > instantiating the member in case T does not fulfill some requirements   
      
   It think it should be possible to realize this using conditional   
   base-classes combined with CRTP, but it is far from trivial.   
      
   > - specialize is_copyconstructible, is_moveconstructible,   
   > is_constructible, ... (etc) like this   
   >   
   >    template   
   >    struct is_copyconstructible>   
   >    : is_copyconstructible  {};   
   >   
   > (I'm not sure though that this is allowed and/or a good idea)   
      
   This is not allowed.   
      
   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