Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Function compile error
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-03-06 18:34:52


AMDG

On 03/06/2013 03:06 PM, gast128 wrote:
> <snip>
>
> void foo()
> {
> std::identity<int> bla;
>
> boost::function<int (int)> fc(bla);
> boost::function<int (int)> fc2 = bla;
> boost::function<int (int)> fc(boost::ref(bla));
> boost::function<int (int)>(bla); //<--
> }
>
> first 3 are ok, but the last one vstudio sees this as redefintion of bla of type
> 'boost::function<int (int)>. What (and why) do I wrong or should use an explicit
> cast in the last case?
>

The last line is treated the same as:
boost::function<int(int)> bla;

You can get around this by using it in a larger
expression or just by wrapping it in parentheses, to
prevent it from being parsed as a declaration. i.e.
(boost::function<int (int)>(bla));

In Christ,
Steven Watanabe


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