title: Substitute for std::array when using boost::asio read_some() function, boost::array crashes at read_some() function call
body: <p>I am working on reading results from a socket read using boost's sockets and a char array. Based on examples I've seen online (including the Boost docs), I have this so far:</p>
  
  <pre><code>#include &lt;boost/asio.hpp&gt;
  #include &lt;array&gt;
  #include &lt;string&gt;
  #define MAXSIZE 1000000
  //...
  void MyClass::processCommand(std::string command)
  {
    boost::asio::io_service io;
    boost::asio::ip::tcp::socket socket(io);
    boost::asio::ip::tcp::endpoint e(boost::asio::ip::address::from_string("127.0.0.1"), 60151);  //Info for the connection I need to make...
    this-&gt;socket.open(boost::asio::ip::tcp::v4());
    this-&gt;socket.connect(e);
    this-&gt;socket.write_some(boost::asio::buffer(command, command.size());
    this-&gt;socket.send(boost::asio::buffer(command, command.size());
  
    std::array&lt;char, MAXSIZE&gt; buffer;
    this-&gt;socket.read_some(boost::asio::buffer(buffer));
  }
  </code></pre>
  
  <p>Based on examples I've seen, it seems this should work. I have a problem though; for whatever reason, my compiler (I'm working in Qt 5.2) seems to refuse to recognize std::array as valid. Even with the <code>#include <code>&lt;array</code>></code> line, the line defining buffer gives an error saying array isn't a member of std. My project lead and I worked for an hour or so trying a bunch of different ways to fix this, including entirely reinstalling the std libraries, but to no avail; the code will still recognize the <code>#include <code>&lt;array</code>></code> line as valid, but then not let me use std::array. I tried to work around this by instead defining buffer as <code>char buffer[MAXSIZE] = ""</code>, but while that compiles it crashes when it reaches the read_some command on the next line. I'm admittedly really new to using Boost, and I'm not sure if there's any other way I could define buffer to make it a valid parameter to pass to the read_some function. If anyone knows how to solve this (either how to pass buffer to read_some without crashes, or how to get std::array to work) I'd really appreciate it. Thanks!</p>
  
  <p><strong>NOTE</strong>: The project I'm working on uses VS2008.</p>
  
  <p><strong>UPDATE</strong>: So far, in addition to the code in the sample code above, I have tried the following:</p>
  
  <ul>
  <li><p>declaring buffer as <code>char buffer[MAXSIZE];</code> This compiles, but the program freezes at the line calling <code>socket.read_some()</code>. I get the same result with <code>char buffer[MAXSIZE] = "";</code></p></li>
  <li><p>declaring buffer as <code>boost::array<code>&lt;char, MAXSIZE</code>> buffer;</code>, both with and without adding a directive line to include <code>boost/array.hpp</code>. This freezes at the same place.</p></li>
  <li><p>based on what I found <a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=516" rel="nofollow">here</a>, tried declaring buffer as <code>std::tr1::array<code>&lt;char, MAXSIZE</code>> buffer;</code>. Also along the same logic, I tried adding <code>using namespace std::tr1;</code> and then defining buffer as <code>array<code>&lt;char, MAXSIZE</code>> buffer;</code>. Neither of these compiled; both gave errors on the line calling <code>read_some()</code> for argument type mismatches.</p></li>
  </ul>
  
  <p>It did occur to me, it is possible, since the ones that seem like they should work tend to freeze at <code>read_some()</code>, that it's taking a long time to read and it's simply timing out? If that's the case I can work around that, I just don't know how to tell if that's what's going on or if it's just crashing.</p>