Work around MSVC rejects-valid bug related to C++11 narrowing conversions.

llvm-svn: 300144
This commit is contained in:
Richard Smith 2017-04-13 00:14:39 +00:00
parent 6df95b7c45
commit 1f5a05bba1
1 changed files with 10 additions and 4 deletions

View File

@ -162,6 +162,10 @@ protected:
// Protect the dtor to ensure this type is never destroyed polymorphically.
~ArgList() = default;
// Implicitly convert a value to an OptSpecifier. Used to work around a bug
// in MSVC's implementation of narrowing conversion checking.
static OptSpecifier toOptSpecifier(OptSpecifier S) { return S; }
public:
/// @name Arg Access
/// @{
@ -192,21 +196,23 @@ public:
template<typename ...OptSpecifiers>
iterator_range<filtered_iterator<sizeof...(OptSpecifiers)>>
filtered(OptSpecifiers ...Ids) const {
OptRange Range = getRange({Ids...});
OptRange Range = getRange({toOptSpecifier(Ids)...});
auto B = Args.begin() + Range.first;
auto E = Args.begin() + Range.second;
using Iterator = filtered_iterator<sizeof...(OptSpecifiers)>;
return make_range(Iterator(B, E, {Ids...}), Iterator(E, E, {Ids...}));
return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}),
Iterator(E, E, {toOptSpecifier(Ids)...}));
}
template<typename ...OptSpecifiers>
iterator_range<filtered_reverse_iterator<sizeof...(OptSpecifiers)>>
filtered_reverse(OptSpecifiers ...Ids) const {
OptRange Range = getRange({Ids...});
OptRange Range = getRange({toOptSpecifier(Ids)...});
auto B = Args.rend() - Range.second;
auto E = Args.rend() - Range.first;
using Iterator = filtered_reverse_iterator<sizeof...(OptSpecifiers)>;
return make_range(Iterator(B, E, {Ids...}), Iterator(E, E, {Ids...}));
return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}),
Iterator(E, E, {toOptSpecifier(Ids)...}));
}
/// @}