Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2006-12-14 16:29:05

"Jeffrey Williams" wrote:
> Hi all,
> The following code compiles on mingw (gcc 3.4.5) but not on VC++ 8.0
> express, and I am asking if anyone could tell me which compiler is right.
> Here is simple test case:
> struct caster
> {
> template<class T> operator boost::function<T>() const;
> };
> void func(boost::function<void(int)>) { }
> void foo()
> {
> func(caster());
> }
> This compiles on mingw (it doesn't link obviously) but it won't even compile
> on VC++ 8.0 express. I am assuming one or the other is incorrect (perhaps
> they both are) so which is it? and also, is there a proper way to do that
> conversion that would work on both compilers. doing a specific conversion
> operator boost::function<void(int)> does work on both, but not the template.
> Jeff

This doesn't compile because function also defines an implicit conversion.
    template<class F>
    function(const F&);
The call is ambiguous. The conversion to boost::function<void(int)> works
because it is more specialized.

I can't think of a way to do this offhand.

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at