Comparing std::pair<> first and last from equal_range

75 Views Asked by At

In the context of a map (template), for the following usage

auto begin = m_map.find(keyBegin);
auto end = m_map.find(keyEnd);

auto p = equal_range(begin,end,val);

        if( !
        (
            p.first == p.second == m_map.end()
        )
  )
{
  //do something
}

The type of keyBegin and keyEnd is unsigned int.

I get the following compilation error:

    error: invalid operands to binary expression 

    ('int' and 'iterator' (aka '__map_iterator<__tree_iterator<std::__1::
    __value_type<unsigned int, char>, std::__1::__tree_node<std::__1::__value_type
<unsigned int, char>, 
    void *> *, long> >'))

    p.first == p.second == m_map.end()

Can someone point out the cause of this error? I am of the understanding that the std::pair<> returned by std::equal_range<> has members of type ForwardIterator for first and second respectively.

0

There are 0 best solutions below