DUChain support of defaulted/deleted functions again

Milian Wolff mail at milianw.de
Sat Jun 18 15:19:22 UTC 2011


Hey there,

Nicolas made me aware of some more details of defaulted/deleted functions in 
C++0x yesterday. Here is an example of all the cases I could think of which 
compiles just fine with g++ 4.6 and -std=c++0x:

class A {
  A() = default;
  A(const A&) = delete;
  virtual ~A();
};
A::~A() = default;
void foo(int) = delete;
int main() {
    return 0;
}

Generally:
- defaulted or deleted functions are definitions
- deleted functions can only be declared once
- the definition of defaulted functions can be out-of-line
- non-member functions can be deleted (i.e. to prevent implicit conversion)

Questions:
- I can't think of an example of using =default on a non-member function 
generally, it's not that clear to me what can and what cannot be defaulted. a 
whitelist would be cool, or if someone could point me to the correct part in 
the spec that defines this

- what do we want to track in the duchain, and where?
* personally I'd like to report errors when someone tries to use deleted 
functions and hide them from code completion
* defaulted otoh is not really neccessary to track imo, or can someone think 
of a reason why this should be accessible from the duchain?

It's pretty clear to me that my current approach is wrong and I'll revert it. 
Instead I think assing a m_isDeleted : 1 or similar to DeclarationData would 
be a good thing:
This would increase the count of size-one bitfields to 8, i.e. shouldn't 
increase the overall size if I'm not mistaken. Furthermore we can then do the 
checks for isDeleted without any dynamic casts. 

I just don't know whether putting it directly into Declaration is a good 
place. For one thing this is a pure C++0x feature, I don't know of any other 
language with a similar feature. To make matters worse only 
FunctionDeclarations can be deleted in C++0x... If preferred I could simply 
create a CppFunctionDeclaration that also tracks the isSignal/isSlot and thus 
cleans our API a bit of Cpp-Isms...

Please, input :)
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110618/f37a0dfc/attachment.sig>


More information about the KDevelop-devel mailing list