'Error C2664 cannot convert argument 1 from 'initializer list' to 'A &&' (compiles on VS2017 but not on VS2015)
I have an issue with this code. I can compile it when I use Visual Studio 2017 (v141) platform toolset. However, when I switch to Visual Studio 2015 (v140), I hit this error:
Error C2664 'void std::vector<A,std::allocator<_Ty>>::push_back(const A &)': cannot convert argument 1 from 'initializer list' to 'A &&'
#include <vector>
#include <iostream>
struct A {
double i;
double j;
int k = -1;
};
int main()
{
std::vector<A> _object_rects;
double i = 150;
double j = 200;
_object_rects.push_back({
i,
j });
std::cout << "print structure: " << std::endl;
std::cout << _object_rects[0].i << std::endl;
std::cout << _object_rects[0].j << std::endl;
std::cout << _object_rects[0].k << std::endl;
system("pause");
return 0;
}
Appreciate any help. Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|