Skip to content

Commit ee2c95d

Browse files
committed
Fix llvm.org/PR33000.
1 parent 8805968 commit ee2c95d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

include/mpark/variant.hpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -415,28 +415,21 @@ namespace mpark {
415415
constexpr auto fmatrix =
416416
make_fmatrix<Visitor &&,
417417
decltype(std::forward<Vs>(vs).as_base())...>();
418-
const std::size_t indices[] = {vs.index()...};
419-
return at(fmatrix, indices)(std::forward<Visitor>(visitor),
420-
std::forward<Vs>(vs).as_base()...);
418+
return at(fmatrix, vs.index()...)(std::forward<Visitor>(visitor),
419+
std::forward<Vs>(vs).as_base()...);
421420
}
422421

423422
private:
424423
template <typename T>
425-
inline static constexpr const T &at_impl(const T &elem,
426-
const std::size_t *) {
424+
inline static constexpr const T &at(const T &elem) {
427425
return elem;
428426
}
429427

430-
template <typename T, std::size_t N>
431-
inline static constexpr auto &&at_impl(const std::array<T, N> &elems,
432-
const std::size_t *index) {
433-
return at_impl(elems[*index], index + 1);
434-
}
435-
436-
template <typename T, std::size_t N, std::size_t I>
428+
template <typename T, std::size_t N, typename... Is>
437429
inline static constexpr auto &&at(const std::array<T, N> &elems,
438-
const std::size_t (&indices)[I]) {
439-
return at_impl(elems, indices);
430+
std::size_t i,
431+
Is... is) {
432+
return at(elems[i], is...);
440433
}
441434

442435
template <typename F, typename... Fs>

0 commit comments

Comments
 (0)