edouarda/brigand

Fold Regression in 1.3.0

robertmaynard opened this issue · 3 comments

Hi,

I have an example of using brigand::fold to build a brigand::list that previously working in brigand 1.2.0. I have attached the code below, but the issue seem to be when the fold operator requires more than 2 template parameters

#include "brigand/brigand.hpp"

template <class T, class U, class ParamCausesBrigandToFail>
struct listify
{
  using type = brigand::push_back<T, brigand::list<U> >;
};

template <class L>
struct build_list
{
  using type =
    brigand::fold< L,
                    brigand::list<>,
                    listify< brigand::_state, brigand::_element, L>
                   >;
};

int main()
{
  //example of using cross product
  using l1 = brigand::list<int*, char, double*, long long>;

  using cp = build_list<l1>::type;
cp &cc = "cp";
  return 0;
}

error message:

/Users/robert/Work/brigand/src/brigand/functions/lambda/apply.hpp:51:70: error: no type named 'type' in
      'brigand::detail::apply<brigand::list<int, char, float, double, long, long long, unsigned int, unsigned char,
      unsigned long>, brigand::list<brigand::list<>, int> >'
  struct apply<F<Ts...>, L, Ls...> : F<typename apply<Ts, L, Ls...>::type...>
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/Users/robert/Work/brigand/src/brigand/functions/lambda/apply.hpp:108:1: note: in instantiation of template class
      'brigand::detail::apply<listify<brigand::_1, brigand::_2, brigand::list<int, char, float, double, long, long long,
      unsigned int, unsigned char, unsigned long> >, brigand::list<brigand::list<>, int> >' requested here
using apply = typename detail::apply<Lambda, brigand::list<Args...>>::type;
^
/Users/robert/Work/brigand/src/brigand/algorithms/detail/fold.hpp:153:44: note: in instantiation of template type alias
      'apply' requested here
                                  brigand::apply<Functor,
                                           ^
/Users/robert/Work/brigand/src/brigand/algorithms/fold.hpp:23:1: note: in instantiation of template class
      'brigand::detail::fold_impl<listify<brigand::_1, brigand::_2, brigand::list<int, char, float, double, long, long
      long, unsigned int, unsigned char, unsigned long> >, brigand::list<>, brigand::list<int, char, float, double,
      long, long long, unsigned int, unsigned char, unsigned long> >' requested here
using fold = typename ::brigand::lazy::fold<Sequence, State, Functor>::type;
^
/Users/robert/Work/Sandbox/src/CompileTimeIntersect/test.cpp:57:14: note: in instantiation of template type alias 'fold'
      requested here
    brigand::fold< L,
             ^
/Users/robert/Work/Sandbox/src/CompileTimeIntersect/test.cpp:69:14: note: in instantiation of template class
      'build_list<brigand::list<int, char, float, double, long, long long, unsigned int, unsigned char, unsigned long>
      >' requested here
  using cp = build_list<l1>::type;

probably a pin problem, try adding pin like here listify< brigand::_state, brigand::_element, pin<L>>

@odinthenerd wrapping L in brigand::pin does solve the problem.

It would be great if the fold test had an example of using brigand::pin. At least for me, after reading the wiki entries, I have been using the tests as a reference guide.

We'll add an example with pin.