Beman Dawes <[EMAIL PROTECTED]> writes: > typedef bool (*is_portable_test)( string & candidate ); > > class scoped_portability_policy : noncopyable > { > public: > explicit scoped_portabiity_policy( is_portable_test f ); > ~scoped_portabiity_policy(); > }; > > The effect of constructing a scoped_portability_policy is to push p > onto a stack. The destructor pops the stack. Class path uses the top > stack entry as the current portability checker. The stack is > initialized with a default portability checker. > > Most programs which wanted a policy other than the default would just > being something like this: > > int main() > { > scoped_portability_policy( posix_portability_check ); > ... > > Although the stack is global, when coupled with > scoped_portability_policy, it is safer than a single global variable > (because library functions which push are guaranteed to pop.) > > Of course it can be subverted by static or heap allocation. (Aside: Is > there a reliable way to prevent static or heap allocation?) > > I'm curious to hear what others would think of the above scheme.
It's expensive to make threadsafe, since it requires a global. -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost