V
Victor Bazarov
I am drawing a blank here...
Is there a way to restrict a class to only instantiate objects with
static storage duration, but no dynamic, and no automatic (hence no
function arguments, either) storage duration?
Disabling dynamic is easy (relatively), just make 'op new' private.
But automatic?
class AllowsOnlyStatics {
???
};
AllowsOnlyStatics OK;
class Other {
AllowsOnlyStatics notOK; // not sure about this one
};
int main() {
static AllowsOnlyStatics OKaswell;
AllowsOnlyStatics notOK; // should produce an error
Other o; // should also produce an error
}
Any ideas?
It's not something that I have to have, I probably can work around
it, but if it's available, I'd be interested to know. Thanks!
V
Is there a way to restrict a class to only instantiate objects with
static storage duration, but no dynamic, and no automatic (hence no
function arguments, either) storage duration?
Disabling dynamic is easy (relatively), just make 'op new' private.
But automatic?
class AllowsOnlyStatics {
???
};
AllowsOnlyStatics OK;
class Other {
AllowsOnlyStatics notOK; // not sure about this one
};
int main() {
static AllowsOnlyStatics OKaswell;
AllowsOnlyStatics notOK; // should produce an error
Other o; // should also produce an error
}
Any ideas?
It's not something that I have to have, I probably can work around
it, but if it's available, I'd be interested to know. Thanks!
V