binary '==' : no operator found which takes a left-hand operand of type 'const T2'
and T2=config_iter
so you need bool config_iter::operator == (const config_iter & other) const;
struct config_iter
{
config_iter(const config::iterator iter) : iter_(iter) {}
operator config::iterator() const { return iter_; }
config::iterator operator() () const { return iter_; }
//////ADD THIS//////////////////////
bool operator == (const config_iter & other) const
{
return iter_ == other.iter_;
}
//////ADD THIS//////////////////////
protected:
config::iterator iter_;
};
//////// SEE HERE ///////////////////////////////////
1>.\boost\variant\variant.hpp(781): error: binary '==' : no operator found which takes a left-hand operand of type 'const T2' (or there is no acceptable conversion)
//////// SEE HERE ///////////////////////////////////
1> .\boost\blank.hpp(58): could be 'bool boost::operator ==(const boost::blank &,const boost::blank &)'
1> while trying to match the argument list '(const T2, const T2)'
1> .\boost\variant\variant.hpp(763) : see reference to function template instantiation 'bool boost::detail::variant::equal_comp::operator ()<T>(const T &,const T &) const' being compiled
1> with
1> [
1> T=T2
1> ]
1> .\boost\variant\variant.hpp(832) : see reference to function template instantiation 'bool boost::detail::variant::comparer::operator ()<const T>(const T &) const' being compiled
1> with
1> [
1> Variant=boost::variant,
1> Comp=boost::detail::variant::equal_comp,
1> T=T2
1> ]
1> .\boost\variant\detail\visitation_impl.hpp(130) : see reference to function template instantiation 'bool boost::detail::variant::invoke_visitor<Visitor>::internal_visit<const T>(T &,int)' being compiled
1> with
1> [
1> Visitor=boost::detail::variant::comparer,boost::detail::variant::equal_comp>,
1> T=T2
1> ]
1> .\boost\variant\detail\visitation_impl.hpp(173) : see reference to function template instantiation 'bool boost::detail::variant::visitation_impl_invoke_impl(int,Visitor &,VoidPtrCV,T *,boost::mpl::true_)' being compiled
1> with
1> [
1> Visitor=boost::detail::variant::invoke_visitor,boost::detail::variant::equal_comp>>,
1> VoidPtrCV=const void *,
1> T=T2
1> ]
1> .\boost\variant\detail\visitation_impl.hpp(256) : see reference to function template instantiation 'bool boost::detail::variant::visitation_impl_invoke(int,Visitor &,VoidPtrCV,T *,NoBackupFlag,int)' being compiled
1> with
1> [
1> Visitor=boost::detail::variant::invoke_visitor,boost::detail::variant::equal_comp>>,
1> VoidPtrCV=const void *,
1> NoBackupFlag=boost::variant::has_fallback_type_,
1> T=T2
1> ]
1> .\boost\variant\variant.hpp(1776) : see reference to function template instantiation 'bool boost::detail::variant::visitation_impl::has_fallback_type_>(const int,const int,Visitor &,VoidPtrCV,boost::mpl::false_,NoBackupFlag,Which *,step0 *)' being compiled
1> with
1> [
1> Visitor=boost::detail::variant::invoke_visitor,boost::detail::variant::equal_comp>>,
1> VoidPtrCV=const void *,
1> T0_=std::string,
1> T1=long double,
//////// SEE HERE ///////////////////////////////////
1> T2=config_iter,
//////// SEE HERE ///////////////////////////////////
1> NoBackupFlag=boost::variant::has_fallback_type_,
1> Which=first_which,
1> step0=first_step
1> ]
// test program with config_iter and indentifier // doesn't compile if identifier::operator==() is in the program
#include #include <iterator> #include <string> #include <vector> #include <list> #include <map>
struct config_iter;
typedef boost::variant var;
typedef std::vector<var> value;
typedef std::mapstd::string,value message; typedef std::mapstd::string,message config;
struct config_iter
{
config_iter(const config::iterator iter) : iter_(iter) {}
operator config::iterator() const { return iter_; }
config::iterator operator() () const { return iter_; }
protected:
config::iterator iter_;
};
struct identifier
{
identifier()
: name_(""), version_({0})
{
// std::cout << "identifier::identifier()" << std::endl;
}
identifier(const std::string & name, const value & version)
: name_(name), version_(version)
{
// std::cout << "identifier::identifier(" << name << "," << version << ")" << std::endl;
}
bool operator == (const identifier & other) const
{
return name_ == other.name_ && version_ == other.version_;
}
private:
// updated by constructor
std::string name_;
value version_;
};
int main()
{
return 0;
}