Re: More keyword abomination by C++0x
Chris Morley wrote:
Overloading the 'delete' keyword do suppress compiler generation of
default
class functions.
My 2p, I'd like to see an additional "label" along with public,protected &
private for delete. Stuff a fn/ctor declaration in there & it gets deleted
including deleting something inherited (but not virtuals).
Which, if IIRC, = delete will achieve. The =delete syntax is for much
wider use than just replacing the terrible hack of declaring something
private and then not defining it.
For example, we can use it to suppress an unwanted conversion at compile
time for ordinary functions:
void foo(int);
void foo(long) = delete;
Now foo cannot be called with a long, instead you get a compile time error.
e.g.
class foo {
public:
void Fn() {stuff}
delete: // or somesuch
foo& operator=(const foo&); // no assignment pls compiler
};
class bar : public foo {
delete:
bar(const bar&); // whack copy ctor
void Fn(); // whack foo's Fn
public:
void barFn() {...}
};
This would be similar in use to the way of doing it now by declaring as
private. The compiler would then throw an error of non-existent fn rather
than a private misuse or link error because no body existed.
See above, the current hack only works for member functions and delays
some diagnostics till link time. It requires the programmer to recognise
the idiom.
Regarding other language constructs, I wouldn't shed a tear if references
were completely erased as the abomination they are! && what?? Pass by value
or pointer suits me just fine :) Source reads better dereferencing with .
all the time but that's about the only benefit I see. What _problem_ do
references even solve?
Do you really not know? Try writing operator functions without something
equivalent to references.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]