有人可以告诉我为什么下面代码的最后一行出现编译器错误吗?
注意:如果我删除以下行,我的代码将被编译且没有错误:
appliedEqualityVisitor(compareValue);
这是代码:
#include "boost/variant/variant.hpp"
#include "boost/variant/apply_visitor.hpp"
using namespace std;
using namespace boost;
template<typename T>
struct CheckOneTypeEquality : public boost::static_visitor<>
{
T const* value;
bool operator()( T const& other ) const
{
return other == *value;
}
template<typename U>
bool operator()( U const& other ) const
{
return false;
}
CheckOneTypeEquality( T const& value_ ):value(&value_) {}
};
typedef variant<int, string> MyVariant;
typedef apply_visitor_delayed_t<CheckOneTypeEquality<MyVariant>> AppliedEqualityVisitorType;
int main(int argc, char **argv)
{
int testValue = 12;
CheckOneTypeEquality<MyVariant> equalityVisitor(testValue);
AppliedEqualityVisitorType appliedEqualityVisitor = apply_visitor(equalityVisitor);
MyVariant compareValue = 13;
appliedEqualityVisitor(compareValue); // <<<<< compile error here
return 0;
}