在"结构提升::enable_if<提升::is_pod<T>,无效>"中没有名为"type"的类型
no type named ‘type’ in ‘struct boost::enable_if<boost::is_pod<T>, void>’
我正在尝试在Linux中编译此存储库,但是在此步骤中遇到了一些麻烦。
*util/BinarySerialization.hpp
template <typename T> inline
typename boost::enable_if<boost::is_pod<T>, void>::type
writeBinary(const T& data, std::ostream& outputStream)
{
...
}
template <typename T> inline
typename boost::enable_if<boost::is_pod<T>, void>::type
writeBinary(const std::vector<T>& data, std::ostream& outputStream)
{
...
}
template <typename T> inline
typename boost::disable_if<boost::is_pod<T>, void>::type
writeBinary(const std::vector<T>& data, std::ostream& outputStream)
{
// write vector length
size_t length = data.size();
outputStream.write(reinterpret_cast<const char*>(&length), sizeof(length));
if (!outputStream) throw IOException();
// write vector data one by one
for (size_t i = 0; i < length; ++i)
writeBinary(data[i], outputStream); // error!
}
void writeBinary(const std::string& data, std::ostream& outputStream);
*序列化/元素BS
.cppvoid bil::writeBinary(const Element& data, std::ostream& outputStream)
{
writeBinary(data.m_name, outputStream);
writeBinary(data.m_options, outputStream);
}
*xdlrc/model/Element.hpp
typedef std::vector<std::string> ConfigurationOptions;
class Element {
public:
Element();
std::string& name();
const std::string& name() const;
ConfigurationOptions& options();
const ConfigurationOptions& options() const;
void clear();
private:
friend void writeBinary(const Element& data, std::ostream& outputStream);
friend void readBinary(Element& data, std::istream& inputStream);
std::string m_name;
ConfigurationOptions m_options;
};
util/BinarySerialization.hpp: 在实例化 'typename boost::d isable_if<boost::is_pod>basic_string
; typename boost::d isable_if<boost::is_pod> , void>::type = void; std::ostream = std::basic_ostream ]':
serialization/ElementBS.cpp:16:45:从这里需要
util/BinarySerialization.hpp:78:21: 错误:调用 'writeBinary(const value_type&, std::ostream&('
writeBinary(data[i], outputStream(;
...
二进制序列化.hpp:31:5:错误:结构提升::enable_if<提升::is_pod><std::__cxx11::basic_string><字符>>,无效>"中没有名为"类型"的类型字符>
ElementBS中的第一个writeBinary.cpp与BinarySerialization.hpp中的最后一个函数匹配,ElementBS中的第二个函数.cpp与第三个函数匹配。但是,writeBinary(data[i], outputStream(;在第三个函数中无法匹配任何函数。我不知道如何解决它;
若要修复编译器错误,请确保声明void writeBinary(const std::string& data, std::ostream& outputStream);
位于函数模板writeBinary
之前。
这是因为在模板实例化期间,将执行依赖名称查找的第二阶段,仅执行依赖于参数的名称查找。由于要writeBinary(const std::string& data, std::ostream& outputStream)
的参数来自命名空间std
因此依赖于参数的名称查找永远不会找到此重载,因为它不在命名空间std
中。
通过在使用该函数的函数模板之前声明该函数,可以使该函数在两阶段查找的第一阶段可用。然后在函数模板实例化(名称查找的第二阶段(期间考虑此名称。
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 呼叫运营商<<临时
- 如何防止clang格式在流运算符调用之间添加换行符<<
- <<操作员在下面的行中工作
- EASTL矢量<向量<int>>连续的
- C - 创建矢量&lt; vector&lt; double&gt;&gt;矩阵具有分配而不是inizializ
- 为什么将此对向量&lt; map&lt; int,int&gt;&gt;中的地图进行更新.失败
- C :对矢量进行排序&lt; struct&gt;(结构有2个整数)基于结构的整数之一
- 明确的专业化“ CheckIntmap&lt;&gt;”实例化
- 什么是模板&lt;&gt;inline bla bla
- 编辑C Qlist&lt; object*&gt; gt;QML代码和一些QML警告中的模型
- eigen :: llt&lt;eigen :: matrixxd&gt;具有不完整的类型
- 错误,包括&lt; ctype&gt;在原子上使用C 11
- std::vector<;uint8_t>;当C++11/14启用时,手动复制而不是调用memcpy
- 如何加入向量&lt; int&gt;到C 中的单个INT
- 是std :: set&lt; std :: future&gt;不可能存在
- 是numeric_limits&lt; int&gt; :: is_modulo从逻辑上矛盾
- opencv 2.4.7在iOS错误背景_segm.hpp #include&lt; list&gt;未找到
- 在修改列表后,std :: list&lt; t&gt; :: end()的值是否会更改
- ///<评论></评论>在Visual Studio中