Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-03-22 15:13:48


On Sun, Mar 21, 2004 at 02:38:23PM +0100, JOAQUIN LOPEZ MU?Z wrote:
> De: Brian McNamara <lorgon_at_[hidden]>
> > I noted with some dismay that duplicate tags are not detected. That
> > is, you are allowed to say
> >
> > struct by_id {};
> > struct by_name {};
> > struct by_foo {};
> > typedef indexed_set<
> > employee,
> > index_list<
> > unique<tag<by_id,by_foo>,identity<employee> >,
> >
> > non_unique<tag<by_name,by_foo>,
> > member<employee,std::string,&employee::name> >
> > >
> > > employee_set;
> >
> > where I have named both indices "by_foo". I would prefer it if the
> > library detected this as a BOOST_STATIC_ASSERT-able error.
>
> Currently, the approach is that the first index with
> a given tag is picked (the reference states this explicitly).
> I'm not convinced the approach you suggest is more
> convenient: maybe eliminating such duplicate tags in a
> metaprogramming environmnt (imagine the indexed_set is
> instantiated by an automatic framework) is not that simple.
> A static *warning* would be ideal here :)

A warning is better than nothing. I still prefer an error.

I don't buy the meta-programming argument. I think it's far more
important to automatically detect an error for "normal" users (who are
probably the majority of users) than to ensure that we don't
"inconvenience" metaprogrammers (the minority). (Metaprogrammers are
smart enough to be able to generate their own unique tags, anyway.)

-- 
-Brian McNamara (lorgon_at_[hidden])

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk