Hi Stephan, Thanks Unfortunately this will do the job only if the flag is known at compile time. What I need is to be able to switch this at runtime. Thanks for the response. Best regards Alex
12 март 2012, понеделник 14:25:56 UTC+2, Stephan Beal написа: > > On Mon, Mar 12, 2012 at 12:37 PM, avasilev <[email protected]> wrote: > >> Unlocker classes? My use case is a conditional auto-unlocker object, >> that may or may not unlock v8, depending on a global setting, so I >> > > Here's a template which does that: > > /** > A sentry class which instantiates a v8::Unlocker > if the boolean value is true or is a no-op if it is false. > */ > template <bool> struct V8Unlocker {}; > > /** > Equivalent to v8::Unlocker. > */ > template <> > struct V8Unlocker<true> : v8::Unlocker > { > }; > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > http://gplus.to/sgbeal > > 12 март 2012, понеделник 14:25:56 UTC+2, Stephan Beal написа: > > On Mon, Mar 12, 2012 at 12:37 PM, avasilev <[email protected]> wrote: > >> Unlocker classes? My use case is a conditional auto-unlocker object, >> that may or may not unlock v8, depending on a global setting, so I >> > > Here's a template which does that: > > /** > A sentry class which instantiates a v8::Unlocker > if the boolean value is true or is a no-op if it is false. > */ > template <bool> struct V8Unlocker {}; > > /** > Equivalent to v8::Unlocker. > */ > template <> > struct V8Unlocker<true> : v8::Unlocker > { > }; > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > http://gplus.to/sgbeal > > 12 март 2012, понеделник 14:25:56 UTC+2, Stephan Beal написа: > > On Mon, Mar 12, 2012 at 12:37 PM, avasilev <[email protected]> wrote: > >> Unlocker classes? My use case is a conditional auto-unlocker object, >> that may or may not unlock v8, depending on a global setting, so I >> > > Here's a template which does that: > > /** > A sentry class which instantiates a v8::Unlocker > if the boolean value is true or is a no-op if it is false. > */ > template <bool> struct V8Unlocker {}; > > /** > Equivalent to v8::Unlocker. > */ > template <> > struct V8Unlocker<true> : v8::Unlocker > { > }; > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > http://gplus.to/sgbeal > > 12 март 2012, понеделник 14:25:56 UTC+2, Stephan Beal написа: > > On Mon, Mar 12, 2012 at 12:37 PM, avasilev <[email protected]> wrote: > >> Unlocker classes? My use case is a conditional auto-unlocker object, >> that may or may not unlock v8, depending on a global setting, so I >> > > Here's a template which does that: > > /** > A sentry class which instantiates a v8::Unlocker > if the boolean value is true or is a no-op if it is false. > */ > template <bool> struct V8Unlocker {}; > > /** > Equivalent to v8::Unlocker. > */ > template <> > struct V8Unlocker<true> : v8::Unlocker > { > }; > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > http://gplus.to/sgbeal > > 12 март 2012, понеделник 14:25:56 UTC+2, Stephan Beal написа: > > On Mon, Mar 12, 2012 at 12:37 PM, avasilev <[email protected]> wrote: > >> Unlocker classes? My use case is a conditional auto-unlocker object, >> that may or may not unlock v8, depending on a global setting, so I >> > > Here's a template which does that: > > /** > A sentry class which instantiates a v8::Unlocker > if the boolean value is true or is a no-op if it is false. > */ > template <bool> struct V8Unlocker {}; > > /** > Equivalent to v8::Unlocker. > */ > template <> > struct V8Unlocker<true> : v8::Unlocker > { > }; > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > http://gplus.to/sgbeal > > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
