Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-06-21 09:39:25


Dave Abrahams wrote:
> I think this may be connected with the void default template
> parameter issue with output_iterator_helper, that Daryle checked in.

Actually, it's not. The errors occur because on MSVC
'boost::detail::iterator_traits<T*>::value_type' and
'boost::detail::iterator_traits<T*>::reference' types are just placeholders,
or more specifically:

++ boost/detail/iterator.hpp, lines 104-121

template <class T> struct undefined;
template <> struct iterator_traits_select<true>
{
    template <class Ptr>
    struct traits
    {
        typedef std::ptrdiff_t difference_type;
        typedef std::random_access_iterator_tag iterator_category;
        typedef Ptr pointer;
#ifdef BOOST_MSVC
// Keeps MSVC happy under certain circumstances. It seems class template
default
// arguments are partly instantiated even when not used when the class
template
// is the return type of a function template.
        typedef undefined<void> value_type;
        typedef undefined<void> reference;
#endif
    };
};

As 'reverse_iterator_generator<>' (indirectly) uses these traits for
defining its default template parameters types, here are the errors. So, how
about replacing the above two lines with these three:

typedef typename boost::remove_pointer<Ptr>::type almost_value_type;
typedef typename boost::remove_const<almost_value_type>::type value_type;
typedef typename boost::add_reference<almost_value_type>::type reference;

It resolves the problem with the test (because simple cases like
'boost::remove_pointer<char*>::type' _do_ work on MSVC), and also gives
users of the library an option to avoid repeating of generators default
parameters for their own classes as well (by writing
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(my_class) ).

BTW, trying to reproduce the errors in the question, I've run into another
two:

1) it seems that 'conversion_traits.hpp' header was checked in with some
diff data in it, which leads to compilation failure:

boost/type_traits/conversion_traits.hpp, line 61, exact text:

<<<<<<< conversion_traits.hpp
      static From* from;
      enum { exists = sizeof( check(*from) ) == sizeof(yes_type) };
=======
      static From _m_from;
      enum { exists = sizeof( _m_check(_m_from) ) == sizeof(yes_type) };
>>>>>>> 1.6
    };

2) on MSVC, the expression 'self::is_input_iter' from the following code
(boost/iterator_adaptors.hpp, line 367)

      typedef typename
boost::detail::if_true<(self::is_input_iter)>::template
      then<
        proxy,
   // else
        Pointer
>::type type;

in some situations lead to "error C2027: use of undefined type ...", there
"undefined type" refers to 'self'. AFAIR, 'self::' qualification here was a
Borland workaround; hmm.. need to re-read John's article on coding intergal
constant expressions to make any useful suggestions here :).

Aleksey


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