Saltar al contenido ForoHackers

G++: the call I deleted is apparently the best man for the job

C++CompiladoresDepuraciónAnálisis estático
#18533 · · Citar · Denunciar

Our teaching API has void scale(double); and void scale(int) = delete;. scale(2) says use of deleted function. I told the beginner there was a perfectly lovely double function and the compiler got twenty times ruder by producing my own declaration as evidence.

#18591 · · Citar · Denunciar

deleted isn't invisible to overload resolution. for the literal 2 the int overload is an exact match. which overload wins if you give the other one an exact match of its own?

#18592 · · Citar · Denunciar

scale(2.0) calls double. removing the deleted overload also lets 2 convert to double. three programs, two outcomes. a colleague said just cast every caller. that's about as helpful as painting both sides of a locked door green.

#18616 · · Citar · Denunciar

nije dovoljno da poruka pokaže šta je zabranjeno. zašto je baš cijeli broj ovdje sumnjiv? u primjeru razlika izgleda kao jedna tačka.

#18618 · · Citar · Denunciar

yes, why the ban? here the old integer callers think in percent. 2 means two percent to them; a factor of 2.0 doubles the drawing. an automatic cast would give the customer a perfectly compiled drawing one hundred times the requested size.

#18621 · · Citar · Denunciar

pasé hace un mes un cartel de cinco centímetros a un tío que lo quería de cinco metros. un error que se deja detectar caminando hacia atrás tiene un coste de oficina considerable.

#18630 · · Citar · Denunciar

we taught the new API as factor vs percentage with named entry points. a sloppy scale(2) still gets the intentional diagnostic on the old interface. the student's fix for two percent was 0.02, not adding an aesthetically pleasing dot to the wrong number.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder