[cfe-dev] fold expressions and std::get?

Seth Cantrell seth.cantrell at gmail.com
Fri Mar 27 16:48:41 PDT 2015


Is the is the following supposed to work in C++1z?

    #include <tuple>

    template<typename Tuple, int... Is>
    auto foo(Tuple const &t) {
      return std::get<Is>(t) * ...;
    }

    int main() {
      using T = std::tuple<int,int,int>;
      foo<T,0,1,2>({2,3,4});
    }

I get compile errors with clang's current implementation. I'm wondering if I've just misunderstood the syntax or if the current implementation isn't complete yet:

    main.cpp:5:10: error: expression contains unexpanded parameter pack 'Is'
      return std::get<Is>(t) * ...;
             ^        ~~
    main.cpp:5:28: error: expected expression
      return std::get<Is>(t) * ...;
                               ^



clang version 3.7.0 (http://llvm.org/git/clang.git 326442a32231880339419bfea101f2887cc8b43b) (http://llvm.org/git/llvm.git 920bbddfe0e9e9af2cacb83073f2dd3b9dabead7)



More information about the cfe-dev mailing list