|
Boost : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-09-15 20:20:38
Dirk Gerrits wrote:
> I believe the example at
> http://www.mywikinet.com/mpl/ref/Reference/find.html
> is broken. Intel's C++ Compiler 6.0 complains that iter
> doesn't have a position member. (The real error message is
> more cryptic of course. ;)
Fixed in sources. Here's the corrected version:
typedef vector<char,int,unsigned,long,unsigned long> types;
typedef find<types,unsigned>::type iter;
BOOST_STATIC_ASSERT(iter::pos::value == 2);
> If this is true then I think the example should make use of
> distance instead:
>
> typedef mpl::vector<char,int,unsigned,long,unsigned long> types;
> typedef mpl::find<types,unsigned>::type iter;
> std::size_t const position =
> mpl::distance<mpl::begin<types>::type, iter>::type::value;
> BOOST_STATIC_ASSERT(position == 2);
It could be written this way too; may be it's even _should_ be re-written as
you suggest, to keep a reader away from a conclusion that "iter::pos" is a
general-supported iterator notation as opposite to a 'vector'-specific one.
> Additionally, when I change the "== 2" to "== 3" then code
> still compiles! All I get is a:
> main.cpp(18): warning #70: incomplete type is not allowed
> BOOST_STATIC_ASSERT(position == 3);
> But no errors.
>
> Is this a fault on my part? Or is BOOST_STATIC_ASSERT broken
> for Intel's compiler?
Yes, it's "broken" in the sense that you get a warning instead of an error
(as promised in the docs). Fixed in the CVS.
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk