Reporting some progress wrt my previous post and adding a meaningful title. The code doesn't break on the iterator def but at the first usage. Error is (translated) can't convert return value of unary func obj to float &. Note that () returns float & Current code #ifndef GRAPH_H #define GRAPH_H #include <boost/config.hpp> #include <vector> #include <iostream> #include <iterator> #include <algorithm> #include <boost/iterator_adaptors.hpp> typedef vector<float> graph_element; template <int index> struct select_component { typedef pair < long, graph_element > argument_type; typedef float result_type; const float & operator()(const argument_type & r) const { return r.second[index]; } float & operator()(argument_type & r) const { return r.second[index]; } }; #endif Use case #include "graph.h" #include <map> #include<vector> int main(int, char*[]) { typedef map < long, graph_element > graph; graph aGraph; aGraph[0].push_back(0.00); aGraph[0].push_back(0.01); aGraph[0].push_back(0.02); aGraph[1].push_back(0.10); aGraph[1].push_back(0.11); aGraph[1].push_back(0.12); aGraph[2].push_back(0.20); aGraph[2].push_back(0.21); aGraph[2].push_back(0.22); aGraph[3].push_back(0.30); aGraph[3].push_back(0.31); aGraph[3].push_back(0.32); boost::projection_iterator_generator < select_component < 0 >, graph::iterator >::type graph_first(aGraph.begin()), graph_last(aGraph.end()); // copy(graph_first, graph_last, // ostream_iterator<float>(cout, "\n")); cout << *graph_first; cout << endl; } Postmodern error message: cd /home/apicco/src/analysis/transcriptome/transmap/ g++ -g -I/home/apicco/install/boost_1_28_0 -o graph-test graph-test.C /home/apicco/install/boost_1_28_0/boost/iterator_adaptors.hpp: In method `typename IteratorAdaptor::reference boost::projection_iterator_policies<AdaptableUnaryFunction>::dereferen ce (const IteratorAdaptor &) const [with IteratorAdaptor = boost::iterator_adaptor<_Rb_tree_iterator<pair<const long int, graph_element>, pair<const long int, graph_element> &, pair<const long int, graph_element> *>, boost::projection_iterator_policies<select_component<0> >, float, float &, float *, boost::detail::default_argument, boost::detail::default_argument>, AdaptableUnaryFunction = select_component<0>]': /home/apicco/install/boost_1_28_0/boost/iterator_adaptors.hpp:867: instantiated from `boost::iterator_adaptor<Base, Policies, Value, Reference, Pointer, Category, Distance>::operator* () const [with Base = _Rb_tree_iterator<pair<const long int, graph_element>, pair<const long int, graph_element> &, pair<const long int, graph_element> *>, Policies = boost::projection_iterator_policies<select_component<0> >, Value = float, Reference = float &, Pointer = float *, Category = boost::detail::default_argument, Distance = boost::detail::default_argument]' graph-test.C:31: instantiated from here /home/apicco/install/boost_1_28_0/boost/iterator_adaptors.hpp:1247: could not convert `(this + 1)->select_component<index>::operator()((&pair<long int,vector<float, allocator<float> >
((+(+(+iter)->boost::iterator_adaptor<Base, Policies, Value, Reference, Pointer, Category, Distance>::base())->_Rb_tree_iterator<_Value, _Ref, _Ptr>::operator* ()))))' to `float &'
Compilation exited abnormally with code 1 at Tue Sep 24 14:52:21