Boost C++ Libraries: Ticket #13207: boost::spirit::istream_iterator unusable with boost::asio::ip::tcp::iostream https://svn.boost.org/trac10/ticket/13207 <p> Hi, </p> <p> I'm really looking forward to using boost::spirit in my next project. Unfortunately, I seem to have hit a roadblock in that the boost::spirit::istream_iterator constructor completely locks up when it is passed a boost::asio::ip::tcp::iostream reference. </p> <p> I come from a (much stronger) C background, so perhaps I'm missing the greater picture, but in the "spirit" of a C++ stream-based API, I would have thought that any input stream would work with spirit's forward iterator - at least that's how I interpreted the documentation. </p> <p> A really simple example is the following: </p> <pre class="wiki">#include &lt;boost/asio.hpp&gt; #include &lt;boost/spirit/include/support_istream_iterator.hpp&gt; #include &lt;iostream&gt; int main( int argc, char *argv[] ) { static const int port = 443; if ( 2 != argc ) { std::cout &lt;&lt; "usage: " &lt;&lt; argv[ 0 ] &lt;&lt; " &lt;fqdn&gt;" &lt;&lt; std::endl; std::cout &lt;&lt; std::endl; std::cout &lt;&lt; "where &lt;fqdn&gt; is e.g. www.google.ca" &lt;&lt; std::endl; return 0; } std::string fqdn( argv[ 1 ] ); std::cout &lt;&lt; "creating fds.." &lt;&lt; std::endl; boost::asio::ip::tcp::iostream fds( fqdn, std::to_string( port ) ); if ( ! fds ) { std::cerr &lt;&lt; "unable to create fds: " &lt;&lt; fds.error().message() &lt;&lt; std::endl; return 1; } std::cout &lt;&lt; "creating istream_iterator.." &lt;&lt; std::endl; boost::spirit::istream_iterator begin( fds ); std::cout &lt;&lt; "created istream_iterator!" &lt;&lt; std::endl; return 0; } </pre><p> Compile with </p> <p> g++ -std=c++14 -o foo foo.cpp -lboost_system </p> <p> Any thoughts? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13207 Trac 1.4.3 Christoper Friedt <chrisfriedt@…> Sat, 16 Sep 2017 13:19:53 GMT <link>https://svn.boost.org/trac10/ticket/13207#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13207#comment:1</guid> <description> <p> The expected output should end with "created istream_iterator!" but instead ends (hangs) with "creating istream_iterator..". </p> </description> <category>Ticket</category> </item> <item> <author>Christoper Friedt <chrisfriedt@…></author> <pubDate>Sat, 16 Sep 2017 13:24:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13207#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13207#comment:2</guid> <description> <p> I suppose that this might be a hint. </p> <p> <a href="http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_tcp_client.cpp">http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_tcp_client.cpp</a> </p> </description> <category>Ticket</category> </item> <item> <author>Christoper Friedt <chrisfriedt@…></author> <pubDate>Sun, 17 Sep 2017 00:23:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13207#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13207#comment:3</guid> <description> <p> Ugh... no .. forget it. Following the blocking_tcp_client pattern would require that I wrap my inputstream with some other class, which would kind of defeat the purpose of abstracting it as an inputstream. </p> </description> <category>Ticket</category> </item> </channel> </rss>