title: Boost binary static_visitor and apply_visitor
body: <p>I have the following code:</p>
  
  <pre><code>typedef boost::variant&lt;LandSearchParameter, WaterSearchParameter&gt; SearchParameter;
  
  enum Visibility{
      CLEAR,
      CLOUDY,
      FOG,
      SMOKE
  };
  
  class DetectionGenerator : public boost::static_visitor&lt;double&gt;{
  public:
  
      DetectionGenerator(const EnvironmentalFactors&amp; factors);
  
      double operator()(const LandSearchParameter&amp; land, Visibility vis) const;
      double operator()(const WaterSearchParameter&amp; water, Visibility vis) const;
  
  private:
  
      const EnvironmentalFactors mFactors;
  };
  </code></pre>
  
  <p>but if I try to use it with <code>boost::apply_visitor</code> in the following manner:</p>
  
  <pre><code>SearchParameter param = globeCover.generateSearch(lat, lon, altitude);
  Visibility vis = weather.generateVisibility(lat, lon, altitude, bearing);
  DetectionGenerator detectGen(envFactors);
  double prob = boost::apply_visitor(detectGen, param, vis);
  </code></pre>
  
  <p>and get the following from gcc:</p>
  
  <blockquote>
    <p>error: no matching function for call to <code>‘apply_visitor(const SearchRescue::DetectionGenerator&amp;, const boost::variant&lt;boost::tuples::tuple&lt;double, double, double, double, double, bool, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt;, boost::tuples::tuple&lt;std::size_t, std::size_t, double, double, double, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt;, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_&gt;&amp;, SearchRescue::Visibility)</code></p>
  </blockquote>
  
  <p>If I attempt to wrap the <code>Visibility</code> enum within a <code>boost::variant</code> I get the same error only instead of <code>Visibility</code> it reads all that junk above and whatever name I chose for the variant.  I've read over the docs on boost for <a href="http://www.boost.org/doc/libs/1_46_1/doc/html/variant/tutorial.html#variant.tutorial.binary-visitation" rel="noreferrer">binary visitation</a> but I'm at a loss.  Due note, all these things are within the same namespace.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>It <em>was</em> my attempt that was the problem.  Not shown above was that I had the visitor as a <code>const</code> variable.  Once I took the <code>const</code> out of the picture, it compiled.  Thank you all for trying to help me out.  Wish I could give more upvotes.</p>