title: Return typename using function, template metaprogramming or any other solution
body: <p>I am writing a caching library as a node-addon to be used as a universal cache across node clusters, and am using <code>boost::message_queue</code> to pass data from one process to another, but I want to support transfer of types, so I have managed to serialize and get typenames of the data being transferred using <code>std::is_same</code> so now on the receiving end I have values: <code>&quot;int&quot;</code> <code>&quot;char&quot;</code> <code>&quot;double&quot;</code>. I need to somehow transform this string into a typename to pass to the template struct to correctly read data into the structure from the message queue. I tried using template metaprogramming like shown <a href="https://stackoverflow.com/questions/36526400/is-there-a-way-to-make-a-function-return-a-typename">here</a> but not sure if this is the correct way to go about things.</p>
  <h3>Used like:</h3>
  <pre class="lang-cpp prettyprint-override"><code>AccessQueue&lt;get_typename(some_type_string)&gt; data_packet;
  // proceed to read data from message_queue
  </code></pre>
  <h3>Serialization of type names:</h3>
  <pre class="lang-cpp prettyprint-override"><code>std::array&lt;char, 16&gt; MemShared::get_cpp_type() {
      std::array&lt;char, 16&gt; result{ 0 };
      if (std::is_same&lt;T, int&gt;::value) {
          safe_copy(result, &quot;int&quot;);
      }
      else if (std::is_same&lt;T, double&gt;::value) {
          safe_copy(result, &quot;double&quot;);
      }
      else if (std::is_same&lt;T, char&gt;::value) {
          safe_copy(result, &quot;char&quot;);
      }
      return result;
  }
  // safe_copy copies data into the std::array and ensure NULL termination
  </code></pre>