शायद मुझे कुछ याद आया है, लेकिन मुझे कोई जानकारी नहीं मिल सकती है जो सिग्नल रावल्यू संदर्भ नहीं ले सकते हैं।क्यूटी 5: सिग्नल घोषित करने में असमर्थ जो रेवल्यू संदर्भ लेता है
तो, मैं निम्नलिखित संकेत घोषणा के साथ एक वर्ग है:
moc_htcodec.cpp: In static member function ‘static void HTCodec::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)’:
moc_htcodec.cpp:71:77: error: cannot bind ‘HTDataMsg’ lvalue to ‘HTDataMsg&&’
case 0: _t->messageDecoded((*reinterpret_cast< HTDataMsg(*)>(_a[1]))); break;
^
In file included from moc_htcodec.cpp:9:0:
../hterm_core/htcodec/htcodec.h:59:9: error: initializing argument 1 of ‘void HTCodec::messageDecoded(HTDataMsg&&)’
void messageDecoded(HTDataMsg &&msg);
^
make: *** [moc_htcodec.o] Error 1
और उत्पन्न MOC-फ़ाइल में कोड है:
signals:
void messageDecoded(HTDataMsg &&msg);
जब मैंने इसे संकलित करने के लिए प्रयास करते हैं, मैं त्रुटियों मिला वास्तव में गलत:
void HTCodec::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
HTCodec *_t = static_cast<HTCodec *>(_o);
switch (_id) {
case 0: _t->messageDecoded((*reinterpret_cast< HTDataMsg(*)>(_a[1]))); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
void **func = reinterpret_cast<void **>(_a[1]);
{
typedef void (HTCodec::*_t)(HTDataMsg &&);
if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&HTCodec::messageDecoded)) {
*result = 0;
}
}
}
}
क्या यह व्यवहार अपेक्षित है? क्या रावल संदर्भों को लेने के संकेतों के लिए अवैध है?
यदि मैं HTDataMsg &&msg
को const HTDataMsg &msg
कहता हूं, तो निश्चित रूप से यह काम करता है।
आप रावल-संदर्भों के साथ क्यों संकेत करना चाहते हैं (और लगता है कि उनके लिए कई रिसीवर हो सकते हैं)? – Jarod42
हम्म। मैं चाहता था कि वे कॉपी ओवरहेड से बचें, लेकिन, ठीक है, मैंने कई रिसीवरों के बारे में सोचा नहीं है (हालांकि वे मेरे विशेष आवेदन में असंभव हैं)। ठीक है, मेरे बुरे, वे वास्तव में अवैध हैं। धन्यवाद। –
यदि आप जानते हैं कि वे अवैध हैं, तो इसे 'और' और 'move' से बाहर ले जाएं। सावधान रहे। – Yakk