Note that there are some explanatory texts on larger screens.

plurals
  1. POerror when using std::copy
    primarykey
    data
    text
    <p>Hey guys I'm having trouble with some code I'm writing for a .obj model parser. Here's the code that's causing the problem:</p> <pre><code>std::istringstream iss(line.substr(1)); std::copy( std::istream_iterator&lt;float&gt;(iss), std::istream_iterator&lt;float&gt;(), std::back_inserter&lt;std::vector&lt;float&gt;&gt;(model.chunks.back().vectices) ); </code></pre> <p>It's basically taking a string passed as a argument like this:</p> <blockquote> <p>v -5.000000 -1.000000 1.000000</p> </blockquote> <p>Then gets the substring from it so it's left with only this:</p> <blockquote> <p>-5.000000 -1.000000 1.000000</p> </blockquote> <p>Finally I use std::copy and get each set of numbers from within the string:</p> <blockquote> <p>vertices[0] = -5.000000<br> vertices[1] = -1.000000<br> vertices[2] = 1.000000 </p> </blockquote> <p>Anyways the main problem here is that I'm getting an error from this line of code:</p> <pre><code>std::back_inserter&lt;std::vector&lt;float&gt;&gt;(model.chunks.back().vectices)); </code></pre> <p>It says "expected token ';' got float" my code still compiles and run's flawlessly though.</p> <p>Although if I replace the floats in that code with std::string's I don't get the error anymore.</p> <pre><code>std::copy( std::istream_iterator&lt;std::string&gt;(iss), std::istream_iterator&lt;std::string&gt;(), std::back_inserter&lt;std::vector&lt;std::string&gt;&gt;(model.chunks.back().vectices) ); </code></pre> <p>I'm using Qt Creator so could this possibly be just a IDE error? Any help would be greatly appreciated!</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