Re: Registrar question... bug?
Status: Alpha
Brought to you by:
madduck
|
From: stephan b. <st...@s1...> - 2004-06-01 12:47:05
|
On Tuesday 01 June 2004 14:16, martin f krafft wrote:
> What's the difference between what you want and what I do with the
> macros? The registrars are created in anonymous namespaces...
> aren't they?
namespace Factory
{
template <typename _Key, typename _BaseType, typename _SubType =
_BaseType,
typename _Builder = Builder<_BaseType, _SubType> >
class Registrar
{
...
> I doubt you want the class to be in an anonymous namespace...
Perhaps not, but for s11n i had horrible problems with
non-anonymous-namespace registrars and .hpp files. i kept getting ODR
violations unless i was *really* careful with class registration
placement.
> > 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.
>
> So we should add an error policy, or figure out a way to make this
> a compiler error. like using static asserts. i'd like that the most.
That's an interesting idea. As a user i would expect to be able to
register whenever i want, so i think a policy would be the better
route. Or simply removing the static one-time check and taking the
last-reg-takes-effect policy. i can't see a reason to keep people from
changing the registrations at arbitrary times. That said, that's not
something people will do, i think. In practice, i've never changed
factories at runtime.
--
----- st...@s1... http://s11n.net
"...pleasure is a grace and is not obedient to the commands
of the will." -- Alan W. Watts
|