Vote count:
0
We can declare such an operator function via typedef declaration as follows:
#include <iostream>
typedef int (*int_ptr)(int, int) ;
struct A
{
private:
int (*_foo)(int a, int b);
public:
operator int_ptr()
{
return _foo;
}
};
int main(){ }
and it works as I was supposed. But is it possible to do that without the typedef declaration? I mean to embed a pointer to function declarator into an operator function declaration. I tried
operator (int *())()
operator (int (*)())()
operator int (*)()()
It didn't work. But, when I tried to use:
operator int *()()
Clang prints the following error:
error: must use a typedef to declare a conversion to 'int *()'
So, such declarators explcitly forbidden by the Standard, don't they? If so, couldn't you get a reference?
asked 1 min ago
To declare a conversion function which has the pointer-to-function return type
Aucun commentaire:
Enregistrer un commentaire