Boost logo

Boost Users :

From: Prashant Thakre (prashant.thakre_at_[hidden])
Date: 2006-07-10 06:25:57


Hi,
 Compiler instantiates the second Binary visitor instead of the first one even
though the template parameters are same.
regards,
Prashant

---------------------------------------------------------------------------
struct add_tuple_visitor: public boost::static_visitor<bool> {

  // Expected this to be instantiated by the compiler.
  // 1.
  template <typename T>
  bool operator()( T & lhs, const T & rhs) const
  {
    lhs += rhs ;
    return true;
  }

  // Compiler considers this as an appropriate fit ..
  // 2.
  template <typename T, typename U>
  bool operator()( T & lhs, const U & rhs) const
  {
    lhs += rhs ;
    return true;
  }

};

struct agg_calc {
 public:
   template <typename T>
   bool operator () (
                T & lhs,
            const T & rhs
   ) const {
         for(
           std::size_t curr_oper = 0;
           curr_oper < num_operations;
           ++v
         ) {
           switch(
             agg_operators.at(curr_oper)
           ) {
             case '+' :
                 boost::apply_visitor(
                          agg_visitor,
                          lhs.at(curr_oper), //vector of variants
                          rhs.at(curr_oper) //vector of variants
                       );
                 break;

             default:
                 break;
            };

         } // for loop

         return true;
   }
                
   //Store the aggregation operators
   agg_types agg_operators;
   std::size_t num_operations;

   // Create visitor objects for delayed form of apply_visitor
   add_tuple_visitor agg_visitor;
};
---------------------------------------------------------------------------


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net