Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2000-11-26 13:07:33


From: "John Maddock" <John_Maddock_at_[hidden]>
> Unfortunately the workaround only seems to work at namespace scope, I've
> tried every which way I can think of to get it working inside template
> classes (which is where is_convertible will be used after all), all to no
> avail. So although it fixes the test program, it really just masks the
> issue, and doesn't (as far as I can tell) help end users.

Have you got a new test program I can have a play with? There might be a
way around it. In general, I've found that using complex expressions
as an enumeration value has more success than as a template argument. For
example, I got static_assert_example_2 to work by changing foo to look like
this:

template <class RandonAccessIterator >
RandonAccessIterator foo(RandonAccessIterator from, RandonAccessIterator
to)
{
   // this template can only be used with
   // random access iterators...
   typedef typename std::iterator_traits<
     RandonAccessIterator
>::iterator_category cat;
   enum { random_access_iterator =
     boost::is_convertible<cat, std::random_access_iterator_tag>::value };
   BOOST_STATIC_ASSERT(random_access_iterator);
   //
   // detail goes here...
   return from;
}

Mark


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