#include <iostream>
#include <string>
#include <boost/bind.hpp>
void foo(std::string const& dummy)
{
std::cout << "Yo: " << dummy << std::endl;
}
int main()
{
int* test;
std::string bar("platypus");
(boost::bind(&foo, bar))(test, test, test, test, test, test, test, test);
}
運行時會打印出「Yo:platypus」。它似乎完全忽略了額外的參數。我希望得到一個編譯錯誤。我不小心通過這種方式在我的代碼中引入了一個錯誤。爲什麼使用額外的參數可以調用Boost.Bind函數?
我仍然很想知道爲什麼允許這種行爲,如果任何人發現的原因:) – 2010-07-31 21:26:43
@約瑟夫:可能太複雜,明確禁止它。 – 2011-07-04 11:53:00