ericniebler / meta

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

Transform interface wrong? #59

Open rrahn opened 5 years ago

rrahn commented 5 years ago

Hi I am wondering if the interface of transform is wrong?

According to: https://github.com/ericniebler/meta/blob/9780f3527839caa83d8f9ebe43953e067351c40b/include/meta/meta.hpp#L1522-L1523

it can only be called with arguments. But where is the fun without a Fun template? And second, why does transform not expect a list of something like all the other meta algorithms but an unpacked list? Right now, I am resorting to the detail implementation which seems to be the correct one.

gabyx commented 5 years ago

It accepts a meta::list as the first argument and a Callable as the second. The documentation is not so user-friendly at this point, yes, maybe one should document it, what the first and second argument shall be.

You need to look closely at the detail namespace:

 namespace detail
 1997         {
 1998             template <typename, typename = void>
 1999             struct transform_
 2000             {
 2001             };
 2002 
 2003             template <typename... Ts, typename Fun>
 2004             struct transform_<list<list<Ts...>, Fun>, void_<invoke<Fun, Ts>...>>
 2005             {
 2006                 using type = list<invoke<Fun, Ts>...>;
 2007             };
 2008 
 2009             template <typename... Ts0, typename... Ts1, typename Fun>
 2010             struct transform_<list<list<Ts0...>, list<Ts1...>, Fun>,
 2011                               void_<invoke<Fun, Ts0, Ts1>...>>
 2012             {
 2013                 using type = list<invoke<Fun, Ts0, Ts1>...>;
 2014             };
 2015         } // namespace detail
gabyx commented 5 years ago

PR #71