Opened 8 years ago

Last modified 8 years ago

#10336 assigned Bugs

compilation error in iterator_range and unordered_map

Reported by: gast128@… Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

I get a compilation error with vc10, iterator_range and a (const) unordered_map (the beta candidate 2 was still ok I think):

#include "stdafx.h"
#include <boost/range/iterator_range.hpp>
#include <boost/unordered_map.hpp>


int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
{
   typedef boost::unordered_map<int, int>            Container;
   typedef Container::const_iterator                 ContainerIterator;
   typedef boost::iterator_range<ContainerIterator>  ContainerIteratorRange;

   const Container cnt;

   ContainerIteratorRange rng(cnt.cbegin(), cnt.cend());
   
   return 0;
}

This gives C2248:

'boost::unordered::iterator_detail::c_iterator<Node,ConstNodePointer>::iterator'

cannot access private typedef declared in class

etc.

Eric: Niebler:

Well, this is unfortunate. It's broken also on msvc-12 and clang trunk, but strangely not on gcc. I thought it might be due to this change in Boost.Range:

github.com/boostorg/range/commit/264017e2a9bdbfcc24517ce05f8ef96df0a8c45b

But reverting that doesn't have any effect. It works on Boost 1.55, so this is definitely a regression.

Can you please file a bug? Neil, can you take a look?

A possible fix: github.com/boostorg/range/pull/19

Change History (3)

comment:1 by Neil Groves, 8 years ago

Status: newassigned

comment:2 by gast128@…, 8 years ago

You can work around it:

   const ContainerIterator itBegin = cnt.cbegin();
   const ContainerIterator itEnd   = cnt.cend();
   
   ContainerIteratorRange rng(itBegin, itEnd);

somehow the 'const' does the trick.

comment:3 by Neil Groves, 8 years ago

I tested this today with Clang on OS X and could not reproduce the problem. I've added a unit test on the develop branch and will watch the tests cycle.

Note: See TracTickets for help on using tickets.