0
我拿起(即複製粘貼)從Boost文檔下面的例子(http://www.boost.org/doc/libs/1_55_0b1/libs/assign/doc/index.html#operator+=):預期不合格-ID之前 '{' 令牌升壓例如
#include <boost/assign/std/vector.hpp> // for 'operator+=()'
#include <boost/assert.hpp>
using namespace std;
using namespace boost::assign; // bring 'operator+=()' into scope
{
vector<int> values;
values += 1,2,3,4,5,6,7,8,9; // insert values at the end of the container
BOOST_ASSERT(values.size() == 9);
BOOST_ASSERT(values[0] == 1);
BOOST_ASSERT(values[8] == 9);
}
會拋出以下錯誤:
$ g++ boost_assign.cpp
boost_assign.cpp:6:1: error: expected unqualified-id before ‘{’ token
{
^
怎麼了?升壓示例不能直接複製粘貼運行嗎?