I would like to use POD types as proxies for some structures. More precisely, I try to do the following thing:
struct Foo { /* some fields */ };
extern Foo global_array[SIZE]; // initialized elsewhere
struct Proxy
{
Foo* pointer_;
}
Proxy get_first_element_as_pointee()
{
return &global_array[0];
}
In the above code, I have a global C array containing Foo structures and I want to get the first one. However, I don't want to expose Foo but a Proxy. The problem is that the conversion does not work. I get the following error message:
error: could not convert ‘& global_array[0]’ from ‘Foo*’ to ‘Proxy’ { return &global_array[0]; }
EDIT: I modified my question so that it will be clearer