c++boost-mp11

What is the purpose of "quoted metafunction" in boost mp11?


I am trying to learn basics of boost::mp11, docs are ok, but one thing I do not understand is the following: what is the purpose of quoted metafunctions? Docs say this:

A quoted metafunction is a class with a public metafunction member called fn, for example

struct Q1 { template<class...> using fn = void; };

struct Q2 { template<class T> using fn = T*; };

struct Q3 { template<class... T> using fn =
  std::integral_constant<std::size_t, sizeof...(T)>; };

Algorithms have "overloads" with suffix _q that take quoted metafunctions as argument, but I still do not understand when to use bla and when to use bla_q.


Solution

  • From slide 14 in http://www.pdimov.com/cpp2/mp11_slides.pdf:

    enter image description here

    So basically, this seems to be your guidance:

    When you get the "can’t expand into a fixed parameter list" error, try quoting the metafunction and using the _q algorithm instead