'Overload == operator for a boost::variant

I have a boost::variant of a bunch of types (int, double, custom class etc) and need to implement an overload for the == operator. How do I go about this?

My error is wrt the == operator, complaining that "too few operators for this operation". What am I missing here? I do not see any errors for the << operator. It complies fine.

namespace xyz
{
        typedef boost::variant< 
            int, 
            double, 
            Date, 
            std::vector<int>, 
            std::vector<double>, 
            std::vector<Date>,
        > someVariant;

        ostream& operator<<(ostream& out, const someVariant& rhs);
        bool operator==(const someVariant& other);
}


Solution 1:[1]

Your << operator takes two arguments, the stream and the variant.

Your operator== takes one argument. If you're defining a free function operator==, the signature should be bool operator==(const someVariant& lhs, const someVariant& rhs).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nathan Pierson