Boost logo

Boost :

From: DY, JERRY U \(SBCSI\) (jd2419_at_[hidden])
Date: 2004-07-27 17:10:25


Sorry. This is the correct version of the new static assertion.

// workaround for aC++ CR JAGaf33512
# define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \
        iterator_adaptor_assert_traversal<my_traversal, cat>();
// typedef int
assertion[sizeof(detail::static_assert_convertible_to<cat>(my_traversal(
)))];

-Jerry

-----Original Message-----
From: DY, JERRY U (SBCSI)
Sent: Tuesday, July 27, 2004 12:54 PM
To: 'boost_at_[hidden]'
Subject: RE: [boost] Re: counting_iterator_test.hpp fails on aC++

Dave,
As you suggested, an auxiliary function template is defined (outside of
the iterator_adaptor class - aC++ doesn't like it if it's a member
function):

// workaround for aC++ CR JAGaf33512
template <typename TR1, typename TR2>
  inline void iterator_adaptor_assert_traversal () {
    typedef int
assertion[sizeof(detail::static_assert_convertible_to<TR2>(TR1()))];
  }

Then the old static assertion is replaced like so:

# define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \
        iterator_adaptor_assert_traversal<my_traversal,
random_access_traversal_tag>();
// typedef iterator_adaptor_assert_traversal<my_traversal, cat>
assert_traversal_t;

I tested this by adapting an ordinary pointer to a forward traversal
iterator and if the program calls the operator+= (calling the adaptor's
advance member function and triggering the static assertion), the
compile fails, the compile succeeds otherwise. There should be no
additional overhead incurred due to the workaround because the function
itself is inlined and all it does is a typedef.

Is this workaround acceptable for check-in? Thanks!

-Jerry


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