Google mock不使用std::vector的boost::variant编译

Google mock不使用std::vector的boost::variant编译,boost,googlemock,Boost,Googlemock,我正在尝试为一些使用boost::variant的接口类创建Google模拟对象 #include <gtest/gtest.h> #include <gmock/gmock.h> #include <boost/variant.hpp> #include <vector> typedef std::vector<int> VectorOfInt; typedef boost::variant<VectorOfInt> V

我正在尝试为一些使用boost::variant的接口类创建Google模拟对象

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <boost/variant.hpp>
#include <vector>

typedef std::vector<int> VectorOfInt;
typedef boost::variant<VectorOfInt> VariantOfVector;

class InterfaceClass
{
public:
     virtual ~InterfaceClass() {}
     virtual void SetSome( const VariantOfVector& ) = 0;
     virtual const VariantOfVector& GetSome() const = 0;
};

class MockInterfaceClass
{
public:
     MOCK_METHOD1( SetSome, void( const VariantOfVector& ) );
     MOCK_CONST_METHOD0( GetSome, const VariantOfVector&() );
};
#包括
#包括
#包括
#包括
typedef std::向量向量;
typedef boost::变量变量向量;
类接口类
{
公众:
虚拟~InterfaceClass(){}
虚空集合集(常量变量向量&)=0;
虚拟常量VariantOfVector&GetSome()常量=0;
};
类接口类
{
公众:
MOCK_方法1(SetSome,void(const VariantOfVector&));
MOCK_CONST_METHOD0(GetSome,CONST VariantOfVector&());
};
当我用

g++mytest.cpp-o mytest

我明白了


/usr/include/boost/variant/detail/variant\u io.hpp:64:错误:与“operator*)不匹配this)->boost::detail::variant::printer>>::out\up>模拟程序似乎试图将operator应用于Igor。回答:顺便说一句,您需要添加operator,整个编译列表都感谢您的回答。也许这会解决我的问题。你知道如何使用operatorWell吗,可能是这样:
template std::ostream&operator
std::ostream& operator <<(std::ostream& out, VariantOfVector const& rhs)
{
    //Print or apply your visitor to **rhs**
    return out;
}