c++ - Wrong std::vector constructor -
I am getting a strange error from Consumable when compiling the code should be the straight line of code.
This code generates an error:
size_t s = 5; Std :: vector & lt; Double & gt; Best Scords {0}, I'm just trying to use to fill a new vector with values of five -1.0. The error I get is Non-continuous expression can not be compressed with type 'size_type' (aka 'unsigned long') to 'double' in the initial list. What's going on? It's compiled exactly:
std :: vector & lt; Double & gt; Best Scores {5, -1.0}; Is she trying to use the initial list creator? I thought you should have two curl braces for it:
std :: vector & lt; Double & gt; Best Scores {{5, -1.0}};
The issue is that you create a vector using a brace-attached initial list are doing. This applies to std :: initializer_list & lt; T & gt; Producer supports this condition, size_t , -1.0 list std :: initializer_list & lt; Double & gt; , so that the manufacturer is chosen you will have to use the old-style, C ++ 03 construction: std :: vector This one is near the brace-attached initials. They do not play well for some standard Library Container Instantiation. You must remember that std :: initializer_list constructor will trump others.
Comments
Post a Comment