
The following code gives me segfault. But if `foo_ptr` is `foo*` it works fine. #include <vector> #include <boost/range/adaptor/indirected.hpp> #include <boost/range/adaptor/transformed.hpp> #include <boost/range/algorithm/for_each.hpp> #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> struct foo{ foo(int _i): i(_i){} virtual void bar() const{ std::cout << "foo::bar::i " << i << std::endl; } int i; }; typedef boost::shared_ptr<foo> foo_ptr; //typedef foo* foo_ptr; foo_ptr trasform(int i){ return foo_ptr(new foo(i)); } int main(){ std::vector<int> vec; vec.push_back(1); using namespace boost::adaptors; using boost::bind; boost::for_each(vec | transformed(bind(&trasform, _1)) | indirected, bind(&foo::bar, _1)); } Is it expected behavior of adaptors ?