зеркало из https://github.com/microsoft/clang-1.git
Allow a conversion from the empty initializer list {} to an
std::initializer_list<T> so long as <T> is known. This conversion has identity rank. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
3953911de1
Коммит
5b4bf13761
|
@ -4301,6 +4301,16 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
|
|||
ImplicitConversionSequence::Worse)
|
||||
Result = ICS;
|
||||
}
|
||||
|
||||
// For an empty list, we won't have computed any conversion sequence.
|
||||
// Introduce the identity conversion sequence.
|
||||
if (From->getNumInits() == 0) {
|
||||
Result.setStandard();
|
||||
Result.Standard.setAsIdentityConversion();
|
||||
Result.Standard.setFromType(ToType);
|
||||
Result.Standard.setAllToTypes(ToType);
|
||||
}
|
||||
|
||||
Result.setListInitializationSequence();
|
||||
Result.setStdInitializerListElement(toStdInitializerList);
|
||||
return Result;
|
||||
|
|
|
@ -166,3 +166,12 @@ namespace Decay {
|
|||
for( auto s : {"A", "BB", "CCC", "DDD"}) { }
|
||||
}
|
||||
}
|
||||
|
||||
namespace PR12436 {
|
||||
struct X {
|
||||
template<typename T>
|
||||
X(std::initializer_list<int>, T);
|
||||
};
|
||||
|
||||
X x({}, 17);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче