c++ - Why do C++11-deleted functions participate in overload resolution? -


Why create C ++ 11?
Why is this useful? Or in other words, why are they hidden instead of being completely removed?

= Delete Syntax calls people to certain tasks with certain criteria Prevents you from doing so. This is mainly to prevent the underlying conversions in certain scenarios. To refuse a special surcharge, he has to take part in the surcharge resolution.

The answer you quoted gives you a perfect example:

  struct onlydouble {onlydouble (std:: Intmax_t) = delete; Onlydouble (double); };  

If the delete function has been completely deleted, then it will = delete create syntax equal to:

  straight only double 2 {onlydouble2 (double); };  

You can do this:

  only W2W (20);  

This is legal C ++ compiler will see all the constructors; None of these takes an integer type directly, but one can take it after an underlying conversion. That's why it says.

  only double Valle (20);  

This is not legal C ++ compiler will see all the constructors, which contain delete D, this is an exact match, Std :: intmax_t (which will actually be a literal match to any integer). Therefore, the compiler will select this and will issue an error immediately because he has selected the Delete d function.

= Delete means "I stop it," not only "this does not exist." This is a very strong statement.

I was saying that the C ++ standard says = to be removed means "it does not exist" instead of "it is not"

That's because we do not need special grammar that "it does not exist." While not declaring "this" specially on this question, we get the implication "I deny it" represents a creation which can be achieved without special grammar so we can Special grammar says "I do not do it" and not the second thing.

The only functionality that you can clearly get by "not so" grammar, someone has to stop it from declaring it later in existence.

Otherwise there is no way to declare that the copy maker is not present, and its existence can cause unnecessary ambiguity.

Copy creator is a special member function. Every class is a copy manufacturer in always . As soon as they always make copy assignment operators, constructors, etc. they carry.

These functions exist; The question is whether it is legal to call them legally. If you try to say that = Delete means that they are not present, the specification should be understood what it means for the existence of a function. It is not a concept that the specification is conducted.

If you try to call a function that is not yet declared / defined, the compiler will return the error but this will be an error due to an undefined identifier , Because "cause does not exist" error (even if your compiler reports this way). Different constructors are called by the surcharge resolution, so their "survival" is handled in that respect.

In every case, the identifier or a producer / district (even identifier, only one type identifier). Operator overloading syntax hides the identifier behind the sugar, but it is still there.

The C ++ specification can not handle the concept of "the function that does not exist". It can control an overload mismatch, it can control a surcharge opacity but it does not know what's not there

and then, less useful " Attempt "is defined as = Delete . And then, read the first part again, you can not do the do not exist with "function present." This is another reason that it has been defined in such a way: because one of the main uses of the syntax for = delete is to force a user to use some parameter types, clearly Is cast from, and even further. Actually, to tease the underlying type of conversion.

Your suggestion would not do this.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -