|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-02-07 09:50:32
OK, I'll try some of these things to get my template metaprogramming stuff
to work with Borland.
-Dave
----- Original Message -----
From: <scleary_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, February 07, 2001 9:26 AM
Subject: RE: [boost] A horrifying Borland thought
> > 3) There are problem handling integral constant expressions, in
particular
> > you must refer to integral constant expressions by their fully qualified
> > names, otherwise they are not recognised as such (I've sporadically had
> > this problem with VC6 as well).
>
> Another workaround I've found for this problem is to surround the integral
> constant expression with an extra set of parenthesis (the following code
may
> be a good example for your gotcha's page, John):
>
>
> #include <iterator>
> #include <limits>
>
> // Purpose of struct: to resolve the "iterator" category for an iterator
or
> // integer (all integers are considered random access)
> template <typename IntegerOrIterator, bool IsInteger>
> struct int_it_category;
> template <typename Integer>
> struct int_it_category<Integer, true>
> { typedef std::random_access_iterator_tag tag; };
> template <typename Iterator>
> struct int_it_category<Iterator, false>
> { typedef typename std::iterator_traits<Iterator>::iterator_category
tag; };
>
> template <typename IntegerOrIterator>
> struct int_it_traits
> {
> // This typedef fails with "E2401 Invalid template argument list"
> typedef typename int_it_category<IntegerOrIterator,
> std::numeric_limits<IntegerOrIterator>::is_integer >::tag category;
>
> // This typedef succeeds
> //typedef typename int_it_category<IntegerOrIterator,
> // (std::numeric_limits<IntegerOrIterator>::is_integer) >::tag
> category;
>
> // So does this one
> //typedef typename int_it_category<IntegerOrIterator,
> // ::std::numeric_limits<IntegerOrIterator>::is_integer >::tag
> category;
> };
>
>
> In any case, it shouldn't be necessary to go the true_struct/false_struct
> route...
>
> -Steve
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk