我正在尝试从Visual Studio 14 2015
编译器切换Visual Studio 16 2019
到编译我的项目(也尝试过Visual Studio 15 2017
,但这导致了同样的问题)。我正在使用irrequietus / typestring,它与旧的编译器可以很好地工作,但是现在会导致错误。
这是一个应该与类型字符串一起使用的类:
// my_custom_class.h
template<typename T>
class MyCustomClass
{
public:
static bool compareTheTypestring(const std::string& other) const {
return std::strcmp(data(), other.c_str()) == 0;
}
}
这是我使用课程的方式:
// use_it.cpp
#include "typestring.hh"
#include "my_custom_class.h"
typedef MyCustomClass<typestring_is("Foo")> FooCompare;
这会吐出以下错误typestring.hh
:
compiler is out of heap space (C1060)
。 还有更多错误use_it.cpp
:
irqus::typeek: no matching overloaded function found (C2672)
Failed to specialize function template 'unknown-type irqus::typeek(irqus::typestring<C...>)'
MyCustomClass
该存储库包含一个类似的问题,但是维护者似乎没有答复。我试图找到替代的typestring实现,但是找不到。有人可以帮我解决这个问题吗?
此问题已在一月报告,此后已回复0。似乎图书馆已不再更新...也许正在寻找替代解决方案
您确实应该在问题中添加尝试做的细节。在我了解您要实现的目标之前,必须通读外部库。我最好的建议是:寻找替代方案。编译时字符串还有其他方法。模板参数可能不是最佳答案。
如果您真的想使用模板参数字符串,则必须自己进行修复。该库可能依赖未定义的行为。所以现在坏了。我正在尝试,但是不是很简单。您可能需要在宏的宏中使用charizing运算符来拆分字符串,然后将char放入元组类型...
template<char c>
class CharType {
public:
static constexpr char Char = c;
};
using FooString = std::tuple<CharType<'F'>, CharType<'o'>, CharType<'o'>>;
或类似的东西。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句