使用升压::信号时"no matching call"编译器错误
"no matching call" compiler error when using boost::signal
在文件 A.hpp 中,我有
extern boost::signal<void (model::Bullet&, Point&, Point&, int)> signal_createBullet;
所以在文件 A.cpp 中,我有
boost::signal<void (model::Bullet&, Point&, Point&, int)> signal_createBullet;
在文件 B.hpp 中,我有一个类Entities
,它有一个静态成员函数receiveSignalCreateBullet
我想与signal_createBullet
连接,如下所示:(为简洁起见,省略命名空间)
class Entities
{
Entities()
{
signal_createBullet.connect(&receiveSignalCreateBullet);
}
public:
static void receiveSignalCreateBullet(const Bullet&, const Point&, const Point&, const int);
};
inline static void receiveSignalCreateBullet(...) { ... }
最后在文件 C.cpp 中,我使用如下signal_createBullet
:
signal_createBullet(bullet, pos, bulletVector, count);
A 和 B 编译成功(使用 g++),但 C 失败并显示以下错误消息:
In member function ‘virtual void thrl::model::SingleStream::shoot(const thrl::utl::Point&, const thrl::utl::Point&, const thrl::utl::Point&) const’:
src/Shot.cpp:25: error: no match for call to ‘(boost::signal4<void, thrl::model::Bullet&, thrl::utl::Point&, thrl::utl::Point&, int, boost::last_value<void>, int, std::less<int>, boost::function4<void, thrl::model::Bullet&, thrl::utl::Point&, thrl::utl::Point&, int> >) (const thrl::model::Bullet&, const thrl::utl::Point&, thrl::utl::Point&, int&)’
/usr/local/include/boost/signals/signal_template.hpp:330: note: candidates are: typename boost::signal4<R, T1, T2, T3, T4, Combiner, Group, GroupCompare, SlotFunction>::result_type boost::signal4<R, T1, T2, T3, T4, Combiner, Group, GroupCompare, SlotFunction>::operator()(T1, T2, T3, T4) [with R = void, T1 = thrl::model::Bullet&, T2 = thrl::utl::Point&, T3 = thrl::utl::Point&, T4 = int, Combiner = boost::last_value<void>, Group = int, GroupCompare = std::less<int>, SlotFunction = boost::function4<void, thrl::model::Bullet&, thrl::utl::Point&, thrl::utl::Point&, int>]
/usr/local/include/boost/signals/signal_template.hpp:370: note: typename boost::signal4<R, T1, T2, T3, T4, Combiner, Group, GroupCompare, SlotFunction>::result_type boost::signal4<R, T1, T2, T3, T4, Combiner, Group, GroupCompare, SlotFunction>::operator()(T1, T2, T3, T4) const [with R = void, T1 = thrl::model::Bullet&, T2 = thrl::utl::Point&, T3 = thrl::utl::Point&, T4 = int, Combiner = boost::last_value<void>, Group = int, GroupCompare = std::less<int>, SlotFunction = boost::function4<void, thrl::model::Bullet&, thrl::utl::Point&, thrl::utl::Point&, int>]
在试图解决这个问题时,我格式化了我的呼叫和错误消息中的第一个候选项,以便更轻松地比较它们:
// my call
‘(
boost::signal
<
void
(
thrl::model::Bullet&,
thrl::utl::Point&,
thrl::utl::Point&,
int
),
boost::last_value<void>,
int,
std::less<int>,
boost::function
<
void
(
thrl::model::Bullet&,
thrl::utl::Point&,
thrl::utl::Point&,
int
)
>
>
)
(
const thrl::model::Bullet&,
const thrl::utl::Point&,
thrl::utl::Point&,
int&
)’
// what g++ expects
typename boost::signal4<R, T1, T2, T3, T4, Combiner, Group, GroupCompare, SlotFunction>::result_type
boost::signal4<R, T1, T2, T3, T4, Combiner, Group, GroupCompare, SlotFunction>::operator()(T1, T2, T3, T4)
[ with
R = void,
T1 = thrl::model::Bullet&,
T2 = thrl::utl::Point&,
T3 = thrl::utl::Point&,
T4 = int,
Combiner = boost::last_value<void>,
Group = int,
GroupCompare = std::less<int>,
SlotFunction = boost::function
<
void
(
thrl::model::Bullet&,
thrl::utl::Point&,
thrl::utl::Point&,
int
)
>
]
// the second candidate is the same as the first, except that it's const
除了候选人使用"可移植"语法这一事实(不,将我的代码切换为使用可移植样式没有区别)我认为这两个调用之间没有区别,除了我的调用中的最后一件事是int&
候选人有int
的地方。 我尝试从信号中删除int
参数,看看这是否是问题所在,但事实并非如此。
有人知道为什么我会收到此错误吗?
static void receiveSignalCreateBullet(const Bullet&, const Point&, const Point&, const int);
为什么这里的参数是常量?在信号声明中,它们不是常量。
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- "no matching function for call to 'Vector::Vector'"错误
- 我在 ifstream input_file(文件名)行中收到错误"no matching function to call";
- 为什么当我在 std::string 中打开文件名的 fstream 时出现"no matching function"错误?
- 从 TVector2 类派生复杂类:"No matching function for call to Complex::Complex()"
- 学习 c++,编译错误"no matching function for call"
- C++ "error: no matching function"
- 尝试实例化模板类的对象时出现"No Matching Constructor"错误
- 结构错误:"no matching function for call to "
- 创建函数变体向量时"No matching function for call"错误
- 为什么"std::isdigit"在 Windows 上报告C++"no matching overloaded function"
- 编译时二叉搜索树错误的反向迭代器表示"no matching function call for operator=()"
- 如果子类中没有构造函数方法,则错误"no matching function for call to 'LGame::LGame(String&)'"
- 提升多精度浮点数128:标准::exp错误:'no matching function for call'
- "error: no matching function for call to",我无法更改结构的定义
- 替换派生对象向量中的对象"no matching function to call"
- 我的程序显示许多错误,"error: no matching function for call to 'getPercentScore'"
- 为什么即使我定义了它们"no matching overload found"也会出现错误
- 为什么有一个指向此代码行(第 7 行)的"no matching call for function"错误?