Here is the code:
int main()
{
std::vector<bool> b(5,false);
auto b0=b[0];
cout<<b0;
b[0]=true;
cout<<b0;
std::vector<int> i(5,false);
auto i0=i[0];
cout<<i0;
i[0]=true;
cout<<i0;
return 0;
}
0100
The variable b0 is with reference type (std::_Bit_reference) while i0 is normal int. What is the right grammar to tell auto to deduce some non reference type, for example, bool?
Aucun commentaire:
Enregistrer un commentaire