Trouble caused by MPL's metafunction arity limit

Hello everyone. I'm working as a student on this year's GSoC and I have ran into a small problem while using MPL in my code. In a nutshell, I have a class template which takes 6 template parameters, and I would like to use it with some MPL algorithms. The problem is, MPL is configured by default to be capable of working with 5 template params only, so lambda expressions of my class won't work with MPL metafunctions. My code is header-only, meaning I cannot (re)define BOOST_MPL_LIMIT_METAFUNCTION_ARITY appropriately, as the MPL headers might have been included before my headers. Out of my 6 template params, 3 are optional, in case this is relevant or can be exploited in any way. Is there any workaround to my problem?

On 07/19/10 20:09, Stefan wrote:
Hello everyone. I'm working as a student on this year's GSoC and I have ran into a small problem while using MPL in my code. In a nutshell, I have a class template which takes 6 template parameters, and I would like to use it with some MPL algorithms. The problem is, MPL is configured by default to be capable of working with 5 template params only, so lambda expressions of my class won't work with MPL metafunctions. [snip] Try:
http://svn.boost.org/svn/boost/sandbox/variadic_templates/ with gcc. It *may* work with any number of arguments; however, I not real sure. Many, but not all, of the mpl templates there have been replaced with ones taking any nunber or arguments.

Larry Evans wrote:
On 07/19/10 20:09, Stefan wrote:
Hello everyone. I'm working as a student on this year's GSoC and I have ran into a small problem while using MPL in my code. In a nutshell, I have a class template which takes 6 template parameters, and I would like to use it with some MPL algorithms. The problem is, MPL is configured by default to be capable of working with 5 template params only, so lambda expressions of my class won't work with MPL metafunctions. [snip] Try:
http://svn.boost.org/svn/boost/sandbox/variadic_templates/
with gcc. It *may* work with any number of arguments; however, I not real sure. Many, but not all, of the mpl templates there have been replaced with ones taking any nunber or arguments.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
That looks like a very nice library. However, I work on a Boost library, therefore I can't rely on features available on recent versions of compilers only (such as variadic templates). Stefan

----- Original Message ----- From: "Stefan" <mstefanro@gmail.com> To: <boost@lists.boost.org> Sent: Tuesday, July 20, 2010 3:09 AM Subject: [boost] Trouble caused by MPL's metafunction arity limit
Hello everyone. I'm working as a student on this year's GSoC and I have ran into a small problem while using MPL in my code. In a nutshell, I have a class template which takes 6 template parameters, and I would like to use it with some MPL algorithms. The problem is, MPL is configured by default to be capable of working with 5 template params only, so lambda expressions of my class won't work with MPL metafunctions. My code is header-only, meaning I cannot (re)define BOOST_MPL_LIMIT_METAFUNCTION_ARITY appropriately, as the MPL headers might have been included before my headers. Out of my 6 template params, 3 are optional, in case this is relevant or can be exploited in any way. Is there any workaround to my problem?
Hi, Either you rely on the user defining it to at least 6 or you ensure it yourself. I think that the macros is not used until you instantiate a class. So, have you tried to redifine it to ensure that it is GE 6 #if defined BOOST_MPL_LIMIT_METAFUNCTION_ARITY #if BOOST_MPL_LIMIT_METAFUNCTION_ARITY <6 #undef BOOST_MPL_LIMIT_METAFUNCTION_ARITY #define BOOST_MPL_LIMIT_METAFUNCTION_ARITY 6 #endif #else #define BOOST_MPL_LIMIT_METAFUNCTION_ARITY 6 #endif #include <boost/mpl/.....hpp> HTH, Vicente

Hi Stefan,
Hello everyone. I'm working as a student on this year's GSoC and I have ran into a small problem while using MPL in my code. In a nutshell, I have a class template which takes 6 template parameters, and I would like to use it with some MPL algorithms. The problem is, MPL is configured by default to be capable of working with 5 template params only, so lambda expressions of my class won't work with MPL metafunctions. My code is header-only, meaning I cannot (re)define BOOST_MPL_LIMIT_METAFUNCTION_ARITY appropriately, as the MPL headers might have been included before my headers. Out of my 6 template params, 3 are optional, in case this is relevant or can be exploited in any way. Is there any workaround to my problem?
The only suitable workaround for your case would be to define a "proxy" template with 5 or less parameters specifically for use in MPL lambda expressions. HTH, -- Aleksey Gurtovoy MetaCommunications Engineering
participants (4)
-
Aleksey Gurtovoy
-
Larry Evans
-
Stefan
-
vicente.botet