title: Why msgpack-c++ do not support vector<float> or vector<double> in my case?
body: <p>See my code below:(you can compile the code with: g++-4.7 demo.cpp -std=c++11 -lmsgpack)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;msgpack.hpp&gt;
  using namespace std;
  
  template&lt;class T&gt;
  void pack(T &amp;t, string &amp;str)
  {
    using namespace msgpack;
    sbuffer buff;
    pack(buff, t); 
    ostringstream is; 
    is &lt;&lt; buff.size() &lt;&lt; buff.data();
    str = string(is.str());
  }
  
  template&lt;class T&gt;
  T unpack(string &amp;str)
  {
    using namespace msgpack;
    unpacked result;
    istringstream ss(str);
    int len;
    string buff;
    ss &gt;&gt; len &gt;&gt; buff;
    unpack(&amp;result, buff.c_str(), len);
  
    auto obj = result.get();
    return obj.as&lt;T&gt;();
  }
  
  int main(int argc, char *argv[]) {
    vector&lt;float&gt; t = {1., 2., 3., 4., 5.};
    string s;
    pack(t, s); 
    auto r = unpack&lt;vector&lt;float&gt; &gt;(s);
    for(auto &amp; v : r)
      std::cout &lt;&lt; v &lt;&lt; std::endl;
    // vector&lt;int&gt; is right
    /* 
    vector&lt;int&gt; t = {1, 2, 3, 4, 5};
    string s;
    pack(t, s); 
    auto r = unpack&lt;vector&lt;int&gt; &gt;(s);
    for(auto &amp; v : r)
      std::cout &lt;&lt; v &lt;&lt; std::endl;
    */
    return 0;
  }
  </code></pre>
  
  <p>There is a strange bug that 'vector', 'vector', 'int', 'double' can work in the above encapsulation, while 'vector', 'vector' can not.</p>
  
  <p>runtime error shows below:</p>
  
  <pre><code>terminate called after throwing an instance of 'msgpack::type_error'
  what():  std::bad_cast
  </code></pre>
  
  <p>but in the below encapsulation, any type can work well:</p>
  
  <pre><code>template&lt;class T&gt;
  void pack(T &amp;t, msgpack::sbuffer sbuf) {
    pack(&amp;sbuf, t);
  }
  
  template&lt;class T&gt;
  T unpack(const msgpack::sbuffer &amp; sbuf) {
    msgpack::unpacked msg;
    msgpack::unpack(&amp;msg, sbuf.data(), sbuf.size());
    auto obj = msg.get();
    return obj.as&lt;t&gt;();
  }
  </code></pre>
  
  <p>What's is the problem in my first code?
  Thanks!</p>