title: boost::spirit binding function providing parameteres as spirit:qi::_val
body: <p>There is a need of providing the values from an object of type boost::variant for an std::pair object. How would you implement this idea using other resources?  Any other way than this is done below?</p>
  
  <pre><code>    struct aggr_pair_visitor : public ::boost::static_visitor&lt;void&gt;
      {
      public:
          explicit aggr_pair_visitor( column_and_aggregate &amp; pair_ ) : pair(pair_)
          {
          }
          void operator()(column_name_t const &amp; column)
          {
              pair.first = column;
          }
          void operator()(unsigned const &amp; faggr)
          {
              if ( faggr &gt; static_cast&lt;unsigned&gt;(sql_faggregate::SUM) || faggr &lt; static_cast&lt;unsigned&gt;(sql_faggregate::AVG) )
                  throw std::runtime_error("Failed to parse aggregate type : Not valid integer");
              else pair.second = static_cast&lt;sql_faggregate&gt;(faggr);
          }
      private:
          column_and_aggregate &amp; pair;
      };
      void apply_col_and_aggr_visitor( column_and_aggregate &amp; col_and_aggr_pair, ::boost::variant&lt; column_name_t, unsigned &gt; const &amp; val )
      {
          aggr_pair_visitor pair_visitor( col_and_aggr_pair );
          ::boost::apply_visitor( pair_visitor, val ); // N.B.!!! Runtime execution of operator()!
      }
      spirit::qi::rule&lt; iterator, column_and_aggregate(), ascii::space_type &gt; agg_pair =
          quoted_string[::boost::bind( &amp;apply_col_and_aggr_visitor, spirit::qi::_val, spirit::qi::_1 )]
          &gt; ':'
          &gt; spirit::int_[::boost::bind( &amp;apply_col_and_aggr_visitor, spirit::qi::_val, spirit::qi::_1 )];
      spirit::qi::rule&lt; iterator, column_and_aggregate_container(), ascii::space_type &gt; aggregates_parser =
            '{'
          &gt; agg_pair[phoenix::push_back(spirit::qi::_val, spirit::qi::_1)] % ',' // N.B.!!! list-redux technic
          &gt; '}';
  </code></pre>