下面的boost代碼可以轉換爲純C++ 11標準庫嗎?是這個boost :: tuple代碼可以轉換爲純std ::標準庫代碼嗎?
我看到std::tuple
和std::for_each
但我似乎無法讓他們玩對方。
我目前使用的是gcc 4.7.2。
CODE
#include <string>
#include <algorithm>
#include <iostream>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
struct DoOutput
{
template<typename T>
void operator()(T const& t) const
{
std::cerr << t << std::endl;
}
void operator()(std::string const& t) const
{
std::cerr << "'" << t << "'" << std::endl;
}
};
int
main(int argc, char* argv[])
{
boost::tuple< std::string, int > t = boost::make_tuple("foo", 42);
boost::fusion::for_each(t, DoOutput());
return 0;
}
'的std ::獲得(T)'將無法編譯。 '我'需要編譯時不變。 – Nawaz
drat - 好點 - 修正... –
@Nawaz +1這也是我想的 – kfmfe04