Libtorrent set_settings 错误
Posted
技术标签:
【中文标题】Libtorrent set_settings 错误【英文标题】:Libtorrent set_settings error 【发布时间】:2015-04-03 16:53:14 【问题描述】:我正在尝试设置会话设置,但遇到了一个我不太明白的错误,我能够正确设置会话设置,根据 Libtorrent 文档,我只需将 session_settings 结构传递给 set_settings 一次我更改了任何值。
using namespace libtorrent;
session* Session;
session_status* Session_Status;
session_settings* Session_Settings;
bool Start_Client_Sess()
Session = new session;
Session_Status = new session_status;
Session_Settings = new session_settings;
Session->settings( );
std::cout << "upload_rate_limit " << Session_Settings->upload_rate_limit << " \n";
std::cout << "dht_announce_interval " << Session_Settings->dht_announce_interval << " \n";
Session_Settings->upload_rate_limit = 200;
Session_Settings->dht_announce_interval = 1800;
Session->set_settings( Session_Settings ); // error
错误:
1>Source\Client_F.cpp(66): error C2664: 'void libtorrent::session::set_settings(const libtorrent::session_settings &)' : cannot convert argument 1 from 'libtorrent::session_settings *' to 'const libtorrent::session_settings &'
1> Reason: cannot convert from 'libtorrent::session_settings *' to 'const libtorrent::session_settings'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
【问题讨论】:
【参考方案1】:正如错误消息所说,您不必将指针传递给此函数。
Session->set_settings( *Session_Settings );
【讨论】:
事实上,一个更好的解决方案是简单地不在堆上分配 Session_Settings 或 Session_Status。以上是关于Libtorrent set_settings 错误的主要内容,如果未能解决你的问题,请参考以下文章