Q
Querejeto
Hello:
Is it possible to detect programmatically the constness of a member
function when it is called?
That is, I would like to see a generic implementation (i.e. it does not
depend on the class Base) of the createInstance function below that
produces the output:
Output:
a const method was called.
a non const method was called.
Code:
class Base {
public:
void constMethod() const {
}
void nonConstMethod() {
}
};
void main() {
Base &base = createInstance<Base>();
base.constMethod();
base.nonConstMethod();
}
Thanks:
Querejeto
Is it possible to detect programmatically the constness of a member
function when it is called?
That is, I would like to see a generic implementation (i.e. it does not
depend on the class Base) of the createInstance function below that
produces the output:
Output:
a const method was called.
a non const method was called.
Code:
class Base {
public:
void constMethod() const {
}
void nonConstMethod() {
}
};
void main() {
Base &base = createInstance<Base>();
base.constMethod();
base.nonConstMethod();
}
Thanks:
Querejeto