|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-11-03 17:47:32
Daniel Earwicker <daniel.earwicker_at_[hidden]> writes:
> Oooh, that's much better. With used_keywords as an empty set in
> empty_arg_list, all it needs in arg_list is:
>
> BOOST_STATIC_ASSERT((!boost::mpl::has_key<
> typename Next::used_keywords, key_type>::type::value));
Use BOOST_MPL_ASSERT_MSG here.
> typedef typename mpl::insert<typename Next::used_keywords,
> key_type>::type used_keywords;
>
> Or is there already something that captures the above pattern, i.e.
> refuses to insert a duplicate?
Not that I know of.
Actually in this case I think I'd prefer to see a solution using
overloading directly, just to cut down on instantiations. The
arg_list, after all, is almost the same structure as the set already.
Something like:
static char (& has_key(K const&) )[2];
BOOST_MPL_ASSERT_MSG(
sizeof(Next::has_key(make<K>())) == 1
, duplicate_keyword, (K)
);
If you could submit a patch to the current CVS along with an
expected-compilation-failure test case, I'd be happy to apply it.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk