gpt4 book ai didi

c++ - 错误 : no match for ‘operator+’ in ‘boost::filesystem::path::filename() const() + "/"’

转载 作者:行者123 更新时间:2023-11-30 02:49:45 25 4
gpt4 key购买 nike

我正在使用此源,但出现此错误:

  In file included from /usr/include/boost/filesystem.hpp:15:0,
[LIST=1]
from luascript.cpp:21:
/usr/include/boost/filesystem/config.hpp:16:5: error: #error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
luascript.cpp: In member function ‘bool LuaInterface::loadDirectory(const string&, Npc*, bool)’:
luascript.cpp:745:61: error: no match for ‘operator+’ in ‘boost::filesystem::path::filename() const() + "/"’
make[1]: *** [luascript.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/dv/src.DEB'
make: *** [all] Error 2
[/LIST]

加上这段代码:

if(boost::filesystem::is_directory(it->status()))
{
if(recursively && !loadDirectory(it->path().filename() + "/" + s, npc, recursively))
return false;
}

最佳答案

你想要

if(recursively && !loadDirectory(it->path() / s, npc, recursively))
return false;

它更短、更优雅,针对分配进行了优化并且平台无关!

IMO 这是非传统运算符重载在 C++ 中实现“即时”直观 eDSL 的非传统运算符重载非常好的罕见情况:)

关于c++ - 错误 : no match for ‘operator+’ in ‘boost::filesystem::path::filename() const() + "/"’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20937308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com