0

これは Visual Studio 2010 では機能しますが、2012 Update 2 (Boost 1.5.3 を使用) では機能しません。

vector<vector<BYTE>> data = assign::list_of (assign::list_of (0x06)(0x02));

コンパイラによって与えられたエラー (更新):

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0(617): error C2668: 'std::vector<_Ty>::vector' : ambiguous call to overloaded function
   with
   [
       _Ty=BYTE
   ]
   C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(786): could be 'std::vector<_Ty>::vector(std::vector<_Ty> &&)'
   with
   [
       _Ty=BYTE
   ]
   C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(693): or       'std::vector<_Ty>::vector(unsigned __int64)'
   with
   [
       _Ty=BYTE
   ]
   while trying to match the argument list '(boost::assign_detail::generic_list<T>)'
   with
   [
   T=int
   ]
... (dozens of more lines)

このエラーを回避する方法はありますか?

4

3 に答える 3

1

問題は埋め込みによるものではなく、list_of を使用して一時的な値を作成することによるものだと思います。それはうまくいくはずです:

vector<BYTE> temp = assign::list_of (0x06)(0x02);
vector<vector<Byte> > data = assign::list_of(temp);
于 2015-11-24T19:23:00.223 に答える
0

私はVC11を持っていないので、ただの推測です...おそらくVC11は、整数をに変換できるBYTEため、move-constructorが使用されるか、tosize_tstd::vector(size_t)constructorが使用されるため、混乱しています。

BYTE暗黙の変換を避けるために、自分自身に変換してみてください:

vector<vector<BYTE>> data = assign::list_of (assign::list_of (static_cast<BYTE>(0x06))(static_cast<BYTE>(0x02)));
于 2013-05-13T11:02:41.093 に答える