मैं टुकड़ाstd :: is_default_constructible <T> त्रुटि, अगर निर्माता निजी
#include <type_traits>
#include <boost/type_traits.hpp>
class C { C() { } };
int main()
{
static_assert(!boost::has_trivial_default_constructor<C>::value, "Constructible");
static_assert(!std::is_default_constructible<C>::value, "Constructible");
}
शर्तों में निम्न है बराबर नहीं हैं, लेकिन पहली शर्त ठीक है और दूसरा निर्माण त्रुटि दिखा सकते हैं काम करता है, कि निर्माता निजी है। कंपाइलर जीसीसी 4.7 ... तो, क्या यह जीसीसी बग है, या इसे मानक द्वारा परिभाषित किया गया है?
http://liveworkspace.org/code/NDQyMD $ 5
ठीक है। चूंकि यह स्थिति वास्तव में असमान हैं - हम कुछ इस
#include <type_traits>
#include <boost/type_traits.hpp>
class C { private: C() noexcept(false) { } };
int main()
{
static_assert(!boost::has_nothrow_constructor<C>::value, "Constructible");
static_assert(!std::is_nothrow_constructible<C>::value, "Constructible");
}
http://liveworkspace.org/code/NDQyMD $ 24
की तरह वैसे भी, मुझे पता है, कि static_assert विफल रहता है नहीं करना चाहिए, का उपयोग के बाद से प्रकार वास्तव में डिफ़ॉल्ट नहीं कर रहे हैं constructible/constructible nothrow नहीं कर सकते। प्रश्न है: क्यों मेरे स्थिर जोर से संकलन त्रुटि है?
मुझे लगता है कि अब आपका क्या मतलब है। यह तब एक बग की तरह दिखता है। – dasblinkenlight
ध्यान दें कि दो लक्षण अलग-अलग गुणों का निरीक्षण करते हैं। – Xeo
@Xeo ठीक है ... और कैसे 'has_nothrow_constructor' और' is_nothrow_constructible' के बारे में है? – ForEveR