Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-10-04 17:06:43

I've checked in a workaround for the problem. The root of the problem is
in a limitation of detail::iterator_traits when there isn't partial
specialization. However, projection_iterator doesn't relly need to rely on
detail::iterator_traits (by using the default reference type). So I
changed projection_iterator to explicitly pass the reference type to


On Thu, 4 Oct 2001, Levente Farkas wrote:

lfarka> hi,
lfarka> this "simple" example cant compile on MSVC 6sp5. is there any chance to
lfarka> compile it or better to give up.
lfarka> ps. anyway such a MemberAccess or MemberSelector functor would be useful
lfarka> to add to boost (this's a general form of the elector can be found in
lfarka> the projection_iterator's example section).
lfarka> yours.
lfarka> -----------------------
lfarka> #include <boost/iterator_adaptors.hpp>
lfarka> #include <boost/functional.hpp>
lfarka> #include <algorithm>
lfarka> #include <vector>
lfarka> #include <list>
lfarka> template<typename Class, typename T>
lfarka> class MemberAccess : public std::unary_function<Class, T>
lfarka> {
lfarka> public:
lfarka> typedef T Class::* Member;
lfarka> MemberAccess(Member m) : member(m) {}
lfarka> const T& operator()(const Class& obj) const { return obj.*member; }
lfarka> T& operator()(Class& obj) const { return obj.*member; }
lfarka> protected:
lfarka> Member member;
lfarka> };
lfarka> struct A
lfarka> {
lfarka> A() : x(0) {}
lfarka> double x;
lfarka> };
lfarka> int main()
lfarka> {
lfarka> std::vector<double> v(10);
lfarka> std::list<A> a(v.size());
lfarka> std::copy(v.begin(), v.end(),
lfarka> boost::make_projection_iterator(a.begin(),
lfarka> MemberAccess<A, double>(&A::x)));
lfarka> return 0;
lfarka> }
lfarka> -----------------------
lfarka> -- Levente "Si vis pacem para bellum!"
lfarka> Info: Unsubscribe: <mailto:boost-unsubscribe_at_[hidden]>
lfarka> Your use of Yahoo! Groups is subject to

 Jeremy Siek
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster ( office phone: (812) 855-3608

Boost list run by bdawes at, gregod at, cpdaniel at, john at