Boost logo

Boost Users :

Subject: Re: [Boost-users] Problems using mpl::if_ and function_types::result_type
From: Allan Nielsen (a_at_[hidden])
Date: 2011-11-25 07:15:46


Hi

I might have simplified the problem too much...

If my template argument is:
F: < int(double) >
Then I needed to define the type:
boost::function< void(bool, int) >

If my template argument is:
F: < void(double) >
Then I needed to define the type:
boost::function< void(bool) >

But I actually got a pretty reply on stackoverflow, where Partial
specializatio is suggested as an solution:

http://stackoverflow.com/questions/8258267/problems-using-mplif-boostfunction-and-a-typedef-to-void

Thanks for the input any way

Regards
Allan W. Nielsen

On Thu, Nov 24, 2011 at 3:26 PM, Max Vasin <max.vasin_at_[hidden]> wrote:
> Hello, Allan, although I do not know the answer I post some results
> that I have got. Your problem has nothing to do with either MPL or
> function_types.
> First of all declaring function to take a void parameter is
> deprecated, the type `void (void)' is in fact `void ()'.  When you
> declare a function type void (R) where R
> depends on a template parameter compiler expects to get an unary
> function type but when R is void the function is nullary (and turning
> an unary function into
> nullary seem to be forbidden). This minimal example demonstates the issue:
>
> template <typename F>
> struct A {
>  typedef void type(F);
> };
>
> int main(int argc, const char *argv[])
> {
>  A<int> ok;
>  A<void> fail;
> }
>
> What you need is partial template specialization. And I will wait for
> the expert answer.
>
> --
> WBR,
> Max Vasin.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net