std::make_pair with float array (float2, unsigned int)
I have a vector containing templated with a float2, unsigned int pair like:
std::vector<std::pair<float2, unsigned int>> myVec;
And then I'm trying to add such a pair to the vector:
unsigned int j = 0;
float2 ab = {1.0, 2.0};
myVec.push_back(std::make_pair(ab, j));
This is how I expect it should work, though when I try to compile it I get
the error:
1>C:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\utility(163): error C2536:
'std::_Pair_base<_Ty1,_Ty2>::std::_Pair_base<_Ty1,_Ty2>::first' : cannot
specify explicit initializer for arrays
1> with
1> [
1> _Ty1=float2 ,
1> _Ty2=unsigned int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\utility(166) : see declaration of
'std::_Pair_base<_Ty1,_Ty2>::first'
1> with
1> [
1> _Ty1=float2 ,
1> _Ty2=unsigned int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\utility(247) : see reference to function template
instantiation 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base<float(&)[2],unsigned
int&>(_Other1,_Other2)' being compiled
1> with
1> [
1> _Ty1=float2 ,
1> _Ty2=unsigned int,
1> _Other1=float (&)[2],
1> _Other2=unsigned int &
1> ]
1> myTest.cpp(257) : see reference to function template
instantiation 'std::pair<_Ty1,_Ty2>::pair<float2(&),unsigned
int&>(_Other1,_Other2)' being compiled
1> with
1> [
1> _Ty1=float2,
1> _Ty2=unsigned int,
1> _Other1=float2 (&),
1> _Other2=unsigned int &
1> ]**strong text**
What is the correct way to add this data type to my pair holding vector?
The float2 type is defined as:
typedef float float2[2];
No comments:
Post a Comment