Boost logo

Boost :

From: DY, JERRY U \(SBCSI\) (jd2419_at_[hidden])
Date: 2004-07-21 18:12:48


Sorry... sent the original e-mail too quickly. Here's why I say that
std::numeric_limits has to be specialized and the is_specialized member
must be set to true if you want a particular type to pass the is_numeric
test.

template <class T>
 struct is_numeric_impl
 {
 typedef ::boost::static_assert_test<
        sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)(
::boost::is_integral<char>::value ) >)
> boost_static_assert_typedef_33 ;
 static const bool value = std::numeric_limits<T>::is_specialized ;
 };

template <> class std::numeric_limits<my_int2> {
public:
        static bool const is_specialized = true;
};

-Jerry

-----Original Message-----
From: DY, JERRY U (SBCSI)
Sent: Wednesday, July 21, 2004 4:08 PM
To: boost_at_[hidden]
Subject: counting_iterator_test.hpp fails on aC++

I'm troubleshooting counting_iterator_test.hpp. In particular:

FILE: counting_iterator_test.cpp
class my_int2 {
public:
        ...
        typedef std::bidirectional_iterator_tag iterator_category;
};

FILE: counting_iterator.hpp

template <class Incrementable, class CategoryOrTraversal, class
Difference>
struct counting_iterator_base {
      typedef typename detail::ia_dflt_help<
          CategoryOrTraversal
        , mpl::apply_if<
              is_numeric<Incrementable>
            , mpl::identity<random_access_traversal_tag>
            , iterator_traversal<Incrementable>
>
>::type traversal;

...
}

The class my_int2 is passed as parameter "Incrementable" to
counting_iterator_base, but is failing the is_numeric test so my_int2 is
just a bidirectional iterator (see mpl::apply_if above). If it passes
the is_numeric test, then it's a random access traversal tag. The way it
passes the is_numeric test is to specialize std::numeric_limits like so:

template <> class std::numeric_limits<my_int2> {
public:
        static bool const is_specialized = false;
};

But I don't find that in the source. It appears that aC++ doing the
right thing, but I know I'm wrong. Could somebody please help?? Thanks!

-Jerry


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