We are upgrading our legacy code to use boost 1.37 from
version 1.34 and have hit a slight hitch. The following (massively simplified)
code no longer compiles. I tried it on more than one compiler and the error
messages aren’t too useful in helping to determine the issue. (The target
compiler will be VS 2k8). Any assistance would be appreciated.
Thanks in advance.
#include "tchar.h"
#include <boost/iterator/filter_iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <list>
class A{};
class B {
public:
typedef std::list<A>::iterator iterator;
iterator begin()
{
return
bs.begin();
}
iterator end()
{
return
bs.end();
}
private:
typedef std::list<A> List;
List bs;
};
template <class
Predicate>
struct FilteredRange
{
typedef
boost::filter_iterator<Predicate, B::iterator> iterator_type;
typedef
boost::iterator_range<iterator_type> range_type;
};
template <typename
Predicate>
typename FilteredRange<Predicate>::range_type
getFilteredRange(B *list)
{
return
boost::make_iterator_range(boost::make_filter_iterator<Predicate>(list->begin(),
list->end()),
boost::make_filter_iterator<Predicate>(list->end(), list->end()));
}
class C {
public:
bool
operator()(const
A &a) const {return
true;}
};
int _tmain(int argc,
_TCHAR* argv[])
{
getFilteredRange<C>(new B).size();
return 0;
}