Boost logo

Boost Users :

From: Derrick Hathaway (d.hathaway_at_[hidden])
Date: 2008-03-05 18:51:41


I apologize if this isn't the sort of question this list is intended
for, but if anyone could help me with my lack of sufficient template
howto skill I would appreciate it.

Essentially what I have is class template for boost::function1<bool,
const ValueType &> like so:

template <typename ValueType>
class predicate
{
public:
   typedef boost::function1<bool, const ValueType&> type;

   struct and
   {
      bool operator()(const ValueType &)()
      {
         return left_() && right();
      }

      type left_;
      type right_;
   };

   struct or { ... };
};

And what I want is to overload the & and | operators for
predicate<ValueType>::type like so:

template <typename ValueType>
typename predicate<ValueType>::type operator &(
   const typename predicate<ValueType>::type &left,
   const typename predicate<ValueType>::type &right)
{
        return typename predicate<ValueType>::and(left, right);
}

The problem is when I compile I get the error message "could not
deduce template argument for 'ValueType'" when I compile. Any idea
what I'm doing wrong? I have attached example code. I am using MS
Visual Studio 8, and boost 1.34.1.

Thanks in advance.

-Derrick





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