【发布时间】:2011-05-21 18:23:38
【问题描述】:
这是怎么回事:
template <typename T>
std::list<T> & operator+=(std::list<T> & first, std::list<T> const& second)
{
std::for_each(second.begin(), second.end(), boost::bind(&std::list<T>::push_back, first, _1));
return first;
}
它编译得很好,但不起作用。
【问题讨论】:
-
“不起作用”到底是什么意思?
-
这并不能回答您的问题,但是如果您的代码确实如此做作(我的意思是,与该问题的示例相反),
std::copy有什么问题std::back_inserter? -
为了补充 Tomalak,在 c++ 中做这件事的标准习惯用法是:
std::copy(second.begin(), second.end(), std::back_inserter(first));
标签: c++ stl boost-bind