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

Richard Smith richard at metafoo.co.uk
Fri Mar 27 17:31:08 PDT 2015


On Fri, Mar 27, 2015 at 4:48 PM, Seth Cantrell <seth.cantrell at gmail.com>
wrote:

> 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) * ...;
>     }
>

No. The syntax for a fold-expression has surrounding parentheses.


>     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)
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150327/cc9a7493/attachment.html>


More information about the cfe-dev mailing list