It is both. By default, boost::bind makes
copies of arguments. The usual way around this is to use boost::ref(),
but in your case, doing boost::ref( _1 ) doesn't make sense, since you're making a reference to the
placeholder,
not the actual parameter passed on line 5.
I _think_ your T is a template parameter just because of the container type -- in all cases you are expecting the
container to hold std::strings. If that is the case, you can try this: (I have not tried it or even compiled it)
1 2 3 4 5 6 7 8 9
|
template< typename Containe >
inline void save_container( std::ostream& file, const std::string& name, const Container& data,
const boost::function<void( std::ostream&, const std::string&, const std::string& ) >& save_func )
{
file << "#begin" << name << "n";
for( Container::const_iterator iter = data.begin(); iter != data.end(); ++iter )
save_func( file, name + "_obj", *iter );
file << "#end" << name << "n";
}
|
Not sure if this will work. The point is that the compiler needs to know when compiling the save_func() call that it
needs to pass the first parameter by non-const reference instead of by value.