I am trying to use the fold expression with clang 3.6 '--std = C ++ 1z', but something I do not quite understand. Function I am testing:
auto minus = [](auto... args) { return (args - ...); }; ... std::cout << minus(10, 3, 2) << std::endl;
according to n4191 , I expect it to expand as a left fold in
(10 - 3) - 2
which gives the result 5, but the result is 9, which, apparently, is a decomposition to the right, i.e.
10 - (3 - 2)
Am I missing something or didn’t understand n4191? Thanks
c ++ clang clang ++ c ++ 17
Ralph zhang
source share