Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Restrict to obj...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 44157 of 48417
Post > Topic >>

Restrict to objects with static storage duration

by "Victor Bazarov" <v.Abazarov@[EMAIL PROTECTED] > Mar 27, 2008 at 10:09 AM

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
-- 
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
 




 10 Posts in Topic:
Restrict to objects with static storage duration
"Victor Bazarov"  2008-03-27 10:09:27 
Re: Restrict to objects with static storage duration
Abhishek Padmanabh <ab  2008-03-27 07:49:00 
Re: Restrict to objects with static storage duration
"Victor Bazarov"  2008-03-27 11:10:08 
Re: Restrict to objects with static storage duration
ppi <vodoom@[EMAIL PRO  2008-03-27 08:38:02 
Re: Restrict to objects with static storage duration
"Victor Bazarov"  2008-03-27 12:58:01 
Re: Restrict to objects with static storage duration
Abhishek Padmanabh <ab  2008-03-27 09:13:29 
Re: Restrict to objects with static storage duration
"Victor Bazarov"  2008-03-27 12:59:27 
Re: Restrict to objects with static storage duration
lbonafide@[EMAIL PROTECTE  2008-03-27 10:05:49 
Re: Restrict to objects with static storage duration
"Victor Bazarov"  2008-03-27 14:11:36 
Re: Restrict to objects with static storage duration
kasthurirangan.balaji@[EM  2008-03-27 22:23:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 9:32:00 CST 2008.