先前的問題及答案(here)顯示,元組的列表可以通過以下方式創建:C++:元組的名單C++ 11/1Y
#include <vector>
#include <boost/tuple/tuple.hpp>
using namespace std;
using boost::tuple;
typedef vector< tuple<int, int> > tuple_list;
在運行時,我沒有得到一個錯誤與C++ 98,C++ 1Y(GCC/GNU在Ubuntu)給出:
error: template argument 1 is invalid
typedef vector< tuple<int, int> > tuple_list;
^
error: template argument 2 is invalid
error: invalid type in declaration before ‘;’ token
typedef vector< tuple<int, int> > tuple_list;
^
任何想法是怎麼回事? (如果我能有其他的線程上評論我也有,但真棒SO說我的名聲太低,無法發表評論!)
你是否傳遞了'-std = C++ 11'編譯器標誌來啓用C++ 11?如果是,那麼編譯器的版本是什麼? – vsoftco
@vsoftco OP使用'boost :: tuple'而不是C++ 11'std :: tuple' – NathanOliver
gcc版本4.8.2(Ubuntu 4.8.2-19ubuntu1) – so860