<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Tobias,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">the >> operator is meant to be used for human provided input, while << operator tries to have a nice formatting. Correctly passing points through streams was obviously not considered frequent/important use-case.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Dženan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 18, 2016 at 5:19 AM, Wood, Tobias <span dir="ltr"><<a href="mailto:tobias.wood@kcl.ac.uk" target="_blank">tobias.wood@kcl.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
While trying to read an itk::Point from stdin, I noticed that the insertion and extraction operators are asymmetric. The insertion operator adds [] round the point and uses commas for delimiters. The extraction operator only expects numbers with white-space as the delimiter. Hence the following code:<br>
<br>
itk::Point<float, 3> A; A[0] = 1.; A[1] = 2.; A[2] = 3.;<br>
itk::Point<float, 3> B;<br>
std::stringstream stream;<br>
stream << A;<br>
stream >> B;<br>
std::cout << "A = " << A << std::endl;<br>
std::cout << "B = " << B << std::endl;<br>
<br>
<br>
Produces this as output:<br>
<br>
A = [1, 2, 3]<br>
B = [0, 0, 0]<br>
<br>
<br>
with no errors or exceptions thrown.<br>
<br>
Is this intended behaviour? It was counter-intuitive to me - but in my experience dealing with formatted input via the extraction operator is a complete pain so I can understand why it was written like this! I found an interesting workaround which involves a custom locale on this Stack Overflow page - <a href="http://stackoverflow.com/questions/1894886/parsing-a-comma-delimited-stdstring" rel="noreferrer" target="_blank">http://stackoverflow.com/questions/1894886/parsing-a-comma-delimited-stdstring</a><br>
<br>
Best wishes,<br>
Toby<br>
_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
</blockquote></div><br></div>