Boost logo

Boost :

Subject: Re: [boost] Need help with workaround for MSVC bug
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-09-18 08:48:23


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 17 September 2009, Emil Dotchevski wrote:
> On MSVC, the following correct code produces error C2896: 'void
> operator ||(T,void (__cdecl *)(tag<X>))' : cannot use function
> template 'void bar(tag<X>)' as a function argument.
>
> struct foo { };
>
> template <int X>
> struct tag { };
>
> template <int X>
> void bar( tag<X> ) { }
>
> template <class T,int X>
> void operator||(T, void(*)(tag<X>)) { }
>
> int main()
> {
> foo()||bar<1>;
> }
>
> My goal is to have an operator|| overload that deduces tag<X>
> implicitly, but without using parenthesis, that is, foo()||bar<1>()
> wouldn't be satisfactory. Doesn't seem possible, but still I decided
> to ask. Any ideas?

Does putting an address-of operator in front of bar help?:

foo()||&bar<1>;

I don't have msvc handy to try it.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqzgZcACgkQ5vihyNWuA4UMGwCg0GRNNW8IY6r0Vv1pxho+wLDt
aYIAn02VTX7HrJZuxTzby+QsgKl2XVKw
=G5Nh
-----END PGP SIGNATURE-----


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk