[英]Can special member functions be defaulted if they use typedefs?
Clang 編譯得很好,但是 GCC 和 MSVC 抱怨operator=
不能默認:
#include <type_traits>
template<class T>
struct S
{
typedef typename std::enable_if<!std::is_enum<T>::value, S>::type Me;
S &operator=(Me const &) = default;
};
int main()
{
S<int> s1, s2;
s1 = s2;
}
這段代碼合法嗎? 如果不是,如果Me
被定義為typedef S Me;
?
鑒於沒有任何相反的跡象,我將回答我自己的問題並說,就我能夠在標准中找到相關條款而言,我認為該代碼是合法的,因此 GCC 和 MSVC錯誤地抱怨。
正如上面有人指出的那樣,似乎有一個錯誤報告跟蹤這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.