@ananas You're thinking about something weird.
I want to do something like this, which, as you can see, is so perfectly cromulent than it compiles and runs:
#include <stdio.h>
#include <stdlib.h>
struct bar {
int paydirt;
};
struct foo {
int some_field_here;
struct bar cheap_dirt;
operator bar &() {
return cheap_dirt;
}
};
void work_on_paydirt (struct bar &object) {
printf("Teh paydirt is %i\n", object.paydirt);
}
struct foo the_foo;
struct bar the_bar;
int main () {
work_on_paydirt(the_foo);
work_on_paydirt(the_bar);
return EXIT_SUCCESS;
}
I just want work_on_paydirt, for historic compatibility reasons, to take struct bar * rather than struct bar & as its argument. Logic-wise, maintenance-wise, there's no difference. Even the generated code is exactly the same (modulo the mangled names). But C++ syntax is only happy to let me define an explicit conversion operator for a struct-to-struct-reference, and not for the same struct's pointer to a struct pointer. I'm not trying to do anything exotic here, or type punning or obfuscatory stuff; I just want the translator to implicitly invoke my type converter for a pointer-to-struct type, just like it can for a referenced-struct type.