Boost C++ Libraries: Ticket #13291: read_until won't compile with Visual Studio 2017 using regex https://svn.boost.org/trac10/ticket/13291 <p> Compiling following code will produce compiler error </p> <pre class="wiki">#include &lt;boost/asio/io_service.hpp&gt; #include &lt;boost/asio/ip/tcp.hpp&gt; #include &lt;boost/asio/read_until.hpp&gt; #include &lt;boost/asio/streambuf.hpp&gt; #include &lt;boost/regex.hpp&gt; int main() { boost::asio::io_service ios; boost::asio::ip::tcp::socket s(ios); boost::asio::streambuf b; boost::system::error_code e; boost::asio::read_until(s, b, boost::regex("i am just a regex"), e); } </pre><pre class="wiki">1&gt;d:\source\boost\boost\asio\impl\read_until.hpp(273): error C2664: 'size_t boost::asio::basic_streambuf&lt;std::allocator&lt;char&gt;&gt;::read_size_helper(boost::asio::basic_streambuf&lt;std::allocator&lt;char&gt;&gt; &amp;,::size_t)': cannot convert argument 1 from 'boost::asio::basic_streambuf_ref&lt;Allocator&gt;' to 'boost::asio::basic_streambuf&lt;std::allocator&lt;char&gt;&gt; &amp;' 1&gt; with 1&gt; [ 1&gt; Allocator=std::allocator&lt;char&gt; 1&gt; ] 1&gt;d:\source\boost\boost\asio\impl\read_until.hpp(404): note: see reference to function template instantiation 'size_t boost::asio::read_until&lt;SyncReadStream,boost::asio::basic_streambuf_ref&lt;Allocator&gt;&gt;(SyncReadStream &amp;,DynamicBuffer &amp;&amp;,const boost::regex &amp;,boost::system::error_code &amp;)' being compiled 1&gt; with 1&gt; [ 1&gt; SyncReadStream=boost::asio::ip::tcp::socket, 1&gt; Allocator=std::allocator&lt;char&gt;, 1&gt; DynamicBuffer=boost::asio::basic_streambuf_ref&lt;std::allocator&lt;char&gt;&gt; 1&gt; ] 1&gt;c:\users\????\error.cpp(12): note: see reference to function template instantiation 'size_t boost::asio::read_until&lt;boost::asio::ip::tcp::socket,std::allocator&lt;char&gt;&gt;(SyncReadStream &amp;,boost::asio::basic_streambuf&lt;std::allocator&lt;char&gt;&gt; &amp;,const boost::regex &amp;,boost::system::error_code &amp;)' being compiled 1&gt; with 1&gt; [ 1&gt; SyncReadStream=boost::asio::ip::tcp::socket 1&gt; ] </pre><p> This can be solved by using same calculation as other methods use </p> <pre class="wiki"> // Need more data. std::size_t bytes_to_read = std::min&lt;std::size_t&gt;( std::max&lt;std::size_t&gt;(512, b.capacity() - b.size()), std::min&lt;std::size_t&gt;(65536, b.max_size() - b.size())); </pre><p> instead of </p> <pre class="wiki"> std::size_t bytes_to_read = read_size_helper(b, 65536); </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13291 Trac 1.4.3 Eric Müller <mueller@…> Wed, 02 May 2018 10:58:16 GMT <link>https://svn.boost.org/trac10/ticket/13291#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13291#comment:1</guid> <description> <p> I also encountered this issue, and overloading the friended <code>read_size_helper</code> (taking <code>basic_streambuf</code> as the first parameter) for <code>basic_streambuf_ref</code> (in <code>boost/asio/basic_streambuf.hpp</code>) might be a fix: </p> <pre class="wiki">/// Adapts basic_streambuf to the dynamic buffer sequence type requirements. #if defined(GENERATING_DOCUMENTATION) template &lt;typename Allocator = std::allocator&lt;char&gt; &gt; #else template &lt;typename Allocator&gt; #endif class basic_streambuf_ref { // ... private: friend std::size_t read_size_helper( basic_streambuf_ref&amp; sb, std::size_t max_size) { return read_size_helper(sb.sb_, max_size); } }; </pre> </description> <category>Ticket</category> </item> </channel> </rss>