This shows you the differences between two versions of the page.
— |
gnucap:manual:tech:delete_dummies [2022/11/25 01:49] (current) felixs created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | It is easier to delete unwanted defaults than implementing dummies. | ||
+ | |||
+ | <code> | ||
+ | class C{ | ||
+ | // explicit C(){ unreachable(); } // note: may be ill formed. | ||
+ | explicit C() = delete; | ||
+ | [..] | ||
+ | }; | ||
+ | </code> | ||
+ | |||
+ | The use of "delete" will produce errors at compile time, much like correcly placed dummies. It's nice to have a real language feature here, to not need to resort to dummies. | ||
+ | |||
+ | NB: There is still a hole. If you don't either delete or make a dummy, you can still get caught. | ||
+ | |||