Opened 17 years ago

Closed 17 years ago

#491 closed Bugs (None)

range, VC 7.1, compile error.

Reported by: sergey_shandar Owned by: Thorsten Ottosen
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Compiler: VC 7.1

Example:
---------
#include <boost/range/iterator.hpp>

template<class Container>
typename boost::range_iterator<const Container>::type
begin(const Container &X) 
{ 
	return 0;
}

int main()
{
	char a[3];
	int b = begin(a);
	return 0;
}
---------

The compile-time error message is
---------
c:\Boost\include\boost-1_33\boost\range\iterator.hpp(37)
: error C2825: 'C::iterator': cannot form a qualified name
        main.cpp(12) : see reference to class template
instantiation 'boost::range_iterator<C>' being compiled
        with
        [
            C=char [3]
        ]
---------

It's a VC 7.1 bug but there is possibility to work
around. Instead of using 
C::iterator by default (existing code shown below):

---------
namespace boost
{
namespace detail
{
    template< typename C >
    struct range_iterator
    {
        typedef BOOST_DEDUCED_TYPENAME C::iterator type;
    };
}
}
---------

Use C::iterator only if C is a class. Code showing the
possible implementation 
is shown below

---------
namespace boost
{
namespace detail
{
    template< typename C, bool IsClass>
    struct range_iterator
    {
        typedef void type;
    };
		
    template< typename C>
    struct range_iterator<C, true>
    {
        typedef BOOST_DEDUCED_TYPENAME C::iterator type;
    };
}
}
---------

Change History (1)

comment:1 by Thorsten Ottosen, 17 years ago

Status: assignedclosed
Note: See TracTickets for help on using tickets.