Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Fill a vector with another vector
    primarykey
    data
    text
    <p>I have two vectors, and I would like to fill the first one with the second. The vectors are declared like this:</p> <pre><code>vector&lt;Vec3&gt; firstVector; </code></pre> <p>Where Vec3 is a struct with float x, y, z. I have tried liked this with assign:</p> <pre><code>secondVector.assign(firstVector.begin(), firstVector.end()); </code></pre> <p>But it stops and complains, that there is problem with the end(). I have also tried pushback, but of course it's not working.</p> <p>As I read before I should do it with assign, but I don't know how to solve it properly.</p> <p><strong>EDIT:</strong></p> <p>The error message with insert and assign are the same:</p> <p>this 0x00000000 ... std::vector > * const</p> <p>[size] CXX0030: Error: expression cannot be evaluated<br> [capacity] CXX0030: Error: expression cannot be evaluated</p> <p>And it points to Visual Studio's vector file to iterator end to the return. With insert it points to iterator begin.</p> <p><strong>THE CODE:</strong></p> <p>The first Vector is also part of a struct:</p> <pre><code>struct o3DModel { vector&lt;Vec3&gt; v_Vertices; }; struct Vec3 { public: Vec3() {} Vec3(float X, float Y, float Z) { x = X; y = Y; z = Z; } float x, y, z; }; </code></pre> <p>I declare the "o3DModel" struct above in my app class like this and send it to my loader class:</p> <pre><code>o3DModel *tfTable; void TheApp::Init() { objLoader-&gt;ImportOBJ(tfTable, "testcube.obj"); } </code></pre> <p>The objLoader class, where I successfully fill my "v_Vertices" vector, where "oModel" is the sent "tfTable":</p> <pre><code>bool OBJLoader::ImportOBJ(o3DModel *oModel, char *strFileName) { FillObjData(oModel); ... return true; } void OBJLoader::FillObjData(o3DModel *oModel) { oModel-&gt;v_Vertices.insert(oModel-&gt;v_Vertices.begin(), v_Vertices.begin(), v_Vertices.end()); // This here with insert outFile2 &lt;&lt; oModel-&gt;v_Vertices[0].x &lt;&lt; "\n"; } </code></pre> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload