ericniebler / meta

A tiny metaprogramming library
Boost Software License 1.0
302 stars 47 forks source link

Fix reverse_fold without concepts #76

Open jkuebart opened 5 years ago

jkuebart commented 5 years ago

I believe there's an error in the reverse_fold implementation in case META_CONCEPT is not set. compose1_ as defined by fold passes the functor's argument as the first argument to the function. Where compose1_ is used in the implementation of reverse_fold, I believe we want to pass it on as the second function argument. Anyway, that's how I interpret Fun(A_N, State_N+1) in the documentation.

Without this change, I get

In file included from examples/calc/calc.cc:1:
meta/include/meta/meta.hpp:141:5: error: no type named 'type' in 'meta::detail::reverse_fold_<meta::list<…>, meta::list<>, (anonymous namespace)::CollectProductions<(anonymous namespace)::Expr> >'
    using _t = typename T::type;
    ^~~~~

My compiler is

$ c++ --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
jkuebart commented 5 years ago

I have since discovered that the tests expect the invocation as written, hence only the documentation needs to be changed ;-)