我正在使用此来源但我收到此错误:
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;
}
答案 0 :(得分:3)
你想要
if(recursively && !loadDirectory(it->path() / s, npc, recursively))
return false;
它更短,更优雅,针对分配和独立于平台进行了优化!
IMO这是一个非常罕见的情况,其中非传统的运营商重载非常以实现"即时" C ++中直观的eDSL:)