文件系统::p ath 构造函数调用失败
filesystem::path constructor call fails
这段代码不能编译,使用 Boost 1.48 和 GCC:
// const char* left, const char* right
boost::filesystem::path p = boost::filesystem::absolute(
boost::filesystem::path(right, boost::filesystem::native), // line 314
boost::filesystem::path(left, boost::filesystem::native) ); // line 315
错误消息:
LoggerImplementation.cpp|314|error: invalid conversion from ‘bool (*)(const std::string&)’ to ‘void*’
LoggerImplementation.cpp|314|error: initializing argument 2 of ‘boost::filesystem3::path::path(const Source&, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type>, void>::type*) [with Source = const char*]’
LoggerImplementation.cpp|315|error: invalid conversion from ‘bool (*)(const std::string&)’ to ‘void*’
LoggerImplementation.cpp|315|error: initializing argument 2 of ‘boost::filesystem3::path::path(const Source&, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type>, void>::type*) [with Source = const char*]’
在 MSVC 下,它进行编译。我该如何解决这个问题?
你的第二个参数(boost::filesystem::native
(是错误的。 boost::filesystem::path
根本没有一个接受这个参数的构造函数 - 将其关闭,代码编译。
事实上,boost::filesystem::native
是一个函数,以您尝试的方式使用它毫无意义。此外,如果 MSVC 编译此代码,这是一个明确的错误(它使用从函数指针到 void*
的隐式转换,根据标准不存在(。
相关文章:
- 函数调用中参数的顺序重要吗
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 使用显式模板参数列表和 [temp.arg.explicit]/3 的函数调用的演绎失败
- 从 C#-DLL 调用函数的 C++ 失败
- std::tie 在从函数调用传递值时失败,并显示"无法绑定非常量左值引用"
- asio::thread_pool 在调用构造函数之前失败
- 为什么它是一个使用GCC的令人震惊的函数调用?模板扣减失败
- 超能力 NDK 安卓:返回 int 在"extern"块中成功,在调用函数中失败
- C++:转发模板成员函数调用失败
- 文件系统::p ath 构造函数调用失败
- 为什么这个C++成员函数调用会失败并出现分段错误
- CUDA 调用在析构函数中失败
- set_new_handler (std::new_handler func) 失败后的构造函数调用,用于内存分配失败
- 运行时检查失败 #0 - ESP 的值未在函数调用中正确保存
- C++ Android 上的代码 - execl() 函数调用失败
- 运算符new失败时的构造函数调用
- 重载的*运算符在多个*操作后调用析构函数时失败
- 为什么非虚拟函数调用即使在dynamic_cast失败后仍然成功
- 错误:没有匹配的函数调用[…]注意:模板参数演绎/替换失败
- C++复制初始化+隐式构造函数调用=失败