Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: = delete - ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 9818 of 9909
Post > Topic >>

Re: = delete - what does this do?

by Alberto Ganesh Barbati <AlbertoBarbati@[EMAIL PROTECTED] > Jul 23, 2008 at 06:29 AM

amarzumkhawala@[EMAIL PROTECTED]
 ha scritto:
> I was looking at the std thread class for c++:
> 
>
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html#thread.threads
> 
> I was wondering what the "= delete" does when declaring a constructor?
> 
> -->      thread(const thread&) = delete;
> 

The "= delete" is a new syntax that will be introduced in C++0x to
declare that a certain function will *not* be provided. It can be used
to suppress the implicit generation of the copy constructor (as in this
case) or assignment operator, replacing the common hackish idiom of
declaring them private. This allows the compiler to provide a more
meaningful diagnostic.

The = deleted can be used on any function, including non-member
functions. For example:

   void f(double x) { /* ... */ }
   void f(int) = deleted;

   f(1.0); // ok
   f(1); // error: function is deleted

without the deleted function, f(1) would have been converted 1 to 1.0
and f(double) would be called.

HTH,

Ganesh

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 7 Posts in Topic:
= delete - what does this do?
amarzumkhawala@[EMAIL PRO  2008-07-22 15:48:25 
Re: = delete - what does this do?
Mathias Gaunard <loufo  2008-07-22 21:02:40 
Re: = delete - what does this do?
Alberto Ganesh Barbati &l  2008-07-23 06:29:44 
Re: = delete - what does this do?
ManicQin <ManicQin@[EM  2008-07-23 07:28:21 
Re: = delete - what does this do?
Francis Glassborow <fr  2008-07-23 07:28:19 
Re: = delete - what does this do?
Francis Glassborow <fr  2008-07-23 19:23:35 
Re: = delete - what does this do?
ManicQin <ManicQin@[EM  2008-07-24 05:34:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 4:24:09 CDT 2008.