我希望有人在这里有一个解决方法。此代码在gcc和VS2010 SP1(Debug x32,Release x32,Debug x64)上编译良好,但对于64位版本构建失败,导致致命错误C1060:编译器超出堆空间。我正在使用Boost 1.52
#include "stdafx.h"
#include <boost/variant.hpp>
#include <string>
#include <vector>
#include <map>
typedef boost::make_recursive_variant<
boost::blank,
std::string,
int,
double,
std::vector<std::vector<int> >,
std::vector<std::vector<double> >,
std::vector<std::vector<std::string> >,
std::map<std::string, std::vector<std::string> >,
std::map<std::string, std::vector<double> >,
std::map<std::string, std::vector<int> >,
std::map<std::string,boost::recursive_variant_>
>::type InfoHolder2;
class Test
{
InfoHolder2 test;
};
class Test3
{};
class Test4
{};
template <class T>
class Base
{
public:
Base(){};
virtual std::string Foo(const T& val, const std::string& header = "") const = 0;
virtual T Bar(const std::string& buffer, size_t offset = 0) const = 0;
};
template <class Payload, class iArchive, class oArchive>
class TestSer : Base<Payload>
{
public:
TestSer():Base()
{ }
virtual std::string Foo(const Payload& holder,const std::string& header = "") const
{
return "";
}
virtual Payload Bar( const std::string& buffer, size_t offset = 0) const
{
Payload retval;
return retval;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
new TestSer<Test, Test3, Test4>();
return 0;
}
每次都失败。如果我减少变量可以处理的元素数量,我可以让它进行编译,但这并不是首选,因为这对我很有用。如果我将类更改为下面的版本,它可以工作。有没有人有任何解决方法的想法?
template <class Payload, class iArchive, class oArchive>
class TestSer
{
public:
TestSer()
{ }
std::string Foo(const Payload& holder,const std::string& header = "") const
{
return "";
}
Payload Bar( const std::string& buffer, size_t offset = 0) const
{
Payload retval;
return retval;
}
};