title: Deduce if type can be stored in boost::variant
body: <p>I'm using <code>boost::variant</code> already for a while, but there are still some questions that leave me puzzled.</p>
  
  <p>The following code is not compiling, as I'm trying to store a <code>std::pair&lt;int, int&gt;</code> to a <code>boost::variant</code>, that can only contain <code>int</code>, <code>double</code> and <code>std::string</code>. Still I need the function <code>convert</code>, but it should throw an exception in case I'm trying to store a type in the <code>boost::variant</code> that it will not fit. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/variant.hpp&gt;
  #include &lt;vector&gt;
  
  typedef boost::variant&lt;int, double, std::string&gt; TVar;
  
  template&lt;typename T&gt;
  std::vector&lt;TVar&gt; convert(const std::vector&lt;T&gt;&amp; vec) {  
      std::vector&lt;TVar&gt; ret;
      for (size_t t = 0; t &lt; vec.size(); t++) {
          ret.push_back(vec[t]);
      }
      return ret;
  }
  
  int main(int arg, char** args) {
      {
          std::vector&lt;double&gt; v = { 3,6,4,3 };
          auto ret=convert(v);
          std::cout &lt;&lt; ret.size() &lt;&lt; std::endl;
      }
      {
          std::vector&lt;bool&gt; v = { true, false, true };
          auto ret=convert(v);
          std::cout &lt;&lt; ret.size() &lt;&lt; std::endl;
      }
      {
          std::vector&lt;std::pair&lt;int, int&gt;&gt; v = { std::make_pair&lt;int, int&gt;(5,4) };
          auto ret = convert(v);
          std::cout &lt;&lt; ret.size() &lt;&lt; std::endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>It seems, that <code>std::enable_if</code> might be part of the solution, but I was unable to bring this to an end. </p>