Re: Registrar question... bug?
Status: Alpha
Brought to you by:
madduck
|
From: stephan b. <st...@s1...> - 2004-06-01 10:48:53
|
On Tuesday 01 June 2004 12:37, martin f krafft wrote: > also sprach stephan beal <st...@s1...> [2004.06.01.1221 +0200]: > > am i correct in thinking that the key 75 would never be registered, > > because of this check in the ctor: > > > > _S_reg() = _S_reg() || _Factory::register_builder(__KEY, > > _M_builder); > > Yes, you are correct. It should probably be static. > > But then again, there's a problem because then it needs to be > initialised, and since libfac is header-only... Eeeek... i can see where this is heading. That's the reason that s11n's registration objects are in anonymous namespaces: to allow such initialization without ODR violations. i banged my head for days trying to figure that out, though. Maybe the Registrar should be moved into an anonymous namespace? > I think I considered that and chose to make the builder non-static > because the size overhead is zero and it's not like you'll create > one million registrars for the same type combo. or? i think you're right. My main concern is the possible end-user confusion when he registers 2 keys for the same type. As a user i would expect the LAST-run registration to take effect, but in fact only the first-run registration would happen. > maybe, however, the initialisation of the default builder can be > done in the macros? i think it can only safely be done if it's in an anonymous namespace, otherwise ODR violations will (may?) become a problem. i had all kinds of headaches with this early on in s11n_CL's development. The anonymous namespaces, while not "pretty", offered a great solution - in fact, the only useful solution i know of. -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |