简体   繁体   中英

Example of ill-formed implicit conversion

N3797::13.3.3.1/2 [over.best.ics] tells about an ill-formed implicit conversion as follows:

Implicit conversion sequences are concerned only with the type, cv-qualification, and value category of the argument and how these are converted to match the corresponding properties of the parameter. Other properties, such as the lifetime, storage class, alignment, or accessibility of the argument and whether or not the argument is a bit-field are ignored. So, although an implicit conversion sequence can be defined for a given argument-parameter pair, the conversion from the argument to the parameter might still be ill-formed in the final analysis.

I have no idead about how can we ever define such a conversion. The thing is all kind of conversions I know are well-formed conversion like user-defined conversion with operatorn A(){ ... } or a standard conversion. Couldn't you provide an example of the ill-formed conversion?

Simple example in §13.3.3.1.4 [over.ics.ref]/p4:

[ Example : a function with an “lvalue reference to int ” parameter can be a viable candidate even if the corresponding argument is an int bit-field. The formation of implicit conversion sequences treats the int bit-field as an int lvalue and finds an exact match with the parameter. If the function is selected by overload resolution, the call will nonetheless be ill-formed because of the prohibition on binding a non- const lvalue reference to a bit-field (8.5.3). end example ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM