Boost logo

Boost :

Subject: Re: [boost] Need help with workaround for MSVC bug
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-09-17 16:51:51


On Thu, Sep 17, 2009 at 1:46 PM, Stewart, Robert <Robert.Stewart_at_[hidden]> wrote:
> 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>;
>> }
>
> I think the problem is that the function template is a __thiscall * rather than the default __cdecl *.  Thus, for MSVC (only), adding the following might solve your problem:
>
>   template <class T, int X>
>   void operator ||(T, void (__thiscall *)(tag<X>))
>   {
>   }

No it isn't __thiscall, bar is a global function template (op|| is also global.)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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