Boost logo

Boost :

Subject: [boost] [heap] typedef T gets prevalence over template parameter
From: Alex Hagen-Zanker (ahh34_at_[hidden])
Date: 2012-09-06 11:55:57


Hi,

The d_ary_heap does not compile (in VS2010) when the Comparison class
contains a typedef T. The typedef takes prevalence over the template
parameter T when the heap is derived from the Comparison class.

I.e. the following pattern occurs:

template<class T, class Cmp> struct heap_base : Cmp
{
     typedef T value_type; // value_type = Cmp::T
}

I don't know if this is a bug, a user issue, or a compiler issue. But it
caused me a lot of headache when I was trying to apply Jeremiah's
indirect_cmp with Boost.Heap.

See below for a complete failing example.

Kind regards, Alex

#include <boost/heap/d_ary_heap.hpp>

struct less
{
   typedef int T;
   bool operator()(const int& a, const int& b) const
   {
     return a < b;
   }
};

int main()
{
   boost::heap::d_ary_heap<int, boost::heap::compare<less>,
boost::heap::arity<4> > my_heap;
   return 0;
}


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