Boost.mpl metafunction with integral value problem
Hi, I've been trying boost::mpl for my current project and hit a problem. Sorry if it is an already known issue. So if we have our own metafucntion: template< typename T, typename Value > func : mpl::void_ {}; it works fine: typedef mpl::find_if< mpl::vector< int, char >, func< mpl::_1, mpl::int_< 10 > >::type iter; ... But if I try to use integral value instead: template< typename T, int Value > func : mpl::void_ {}; and typedef mpl::find_if< mpl::vector< int, char >, func< mpl::_1, 10
::type iter;
It fails on gcc 3.3.3 nor 3.4.3. So is it a limitation on language or compiler or library? I mean should second variant compile in generic? Regards, Vyacheslav
Vyacheslav Kononenko
Hi,
I've been trying boost::mpl for my current project and hit a problem. Sorry if it is an already known issue. So if we have our own metafucntion: template< typename T, typename Value > func : mpl::void_ {};
it works fine: typedef mpl::find_if< mpl::vector< int, char >, func< mpl::_1, mpl::int_< 10 > >::type iter; ...
But if I try to use integral value instead: template< typename T, int Value > func : mpl::void_ {};
and
typedef mpl::find_if< mpl::vector< int, char >, func< mpl::_1, 10
::type iter;
It fails on gcc 3.3.3 nor 3.4.3.
No surprise. This func doesn't fit the Metafunction concept: http://www.boost.org/libs/mpl/doc/refmanual/metafunction.html A metafunction is a class or a class template that represents a function invocable at compile-time. An non-nullary metafunction is invoked by instantiating the class template with particular template parameters (metafunction arguments); the result of the metafunction application is accessible through the instantiation's nested type typedef. All metafunction's arguments must be types (i.e. only type ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ template parameters are allowed). A metafunction can have a variable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ number of parameters. A nullary metafunction is represented as a (template) class with a nested type typename member. HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com
--- David Abrahams
No surprise. This func doesn't fit the Metafunction concept:
http://www.boost.org/libs/mpl/doc/refmanual/metafunction.html
A metafunction is a class or a class template that represents a function invocable at compile-time. An non-nullary metafunction is invoked by instantiating the class template with particular template parameters (metafunction arguments); the result of the metafunction application is accessible through the instantiation's nested type typedef. All metafunction's arguments must be types (i.e. only type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
template parameters are allowed). A metafunction can have a variable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ number of parameters. A nullary metafunction is represented as a (template) class with a nested type typename member.
HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Oh my fault, thanks. Regards, Vyacheslav BTW Is this a good place to ask such question or [boost] is better?
participants (3)
-
David Abrahams
-
Vyacheslav Kononenko
-
Vyacheslav Kononenko