विजुअल स्टूडियो 2010 और विजुअल स्टूडियो 2012 इस कोड को संकलित करने में विफल क्यों होता है?विजुअल स्टूडियो बूलियन ऑपरेशंस के संदर्भ में कास्ट (रूपांतरण) ऑपरेटर टेम्पलेट (टी = बूल) को तुरंत चालू करने में विफल रहता है
Codepad.org, Xcode, जीसीसी, LLVM, बजना सब कोई समस्या नहीं है, लेकिन दृश्य स्टूडियो बिस्तर poops:
struct S {
template <class T> inline operator T() const { return T(); }
};
int main() {
// NOTE: "S()" denotes construction in these examples
struct F {
void operator() (bool) { }
static void toint (int) { }
static void tostr (char const*) { }
};
bool b1 = S(); // Okay
bool b2 (S()); // Okay
F() (S()); // Okay
F::toint (S());// Okay
F::tostr (S());// Okay
S() || false; // Error: error C2676: binary '||' : 'vf::S' does
// not define this operator or a conversion to a type
// acceptable to the predefined operator
return 0;
}
explicit
कीवर्ड को जोड़ने का जीसीसी या बजना के लिए एक बात नहीं बदलता है। त्रुटि का उत्पादन संदेश है:
error C2676: binary '||' : 'S' does not define this operator or a
conversion to a type acceptable to the predefined operator
और त्रुटि संदेश है ...? – ybungalobill
आप वहां कास्ट चिपक सकते हैं। – chris
* यह * क्या करना चाहिए? –