overload

Biotronic simen.kjaras at gmail.com
Fri Dec 15 08:57:23 UTC 2017


On Thursday, 14 December 2017 at 22:47:15 UTC, dark777 wrote:
> I know that this community is not from c ++, but for some time 
> I studied how to do overload of ostream operators in c ++ and I 
> even managed to get to this result, I got to this result in 
> another post done here but I did not understand the that it 
> returns this error below:
>
>
> bin2.cxx:44:43: error: expected ‘,’ or ‘...’ before ‘(’ token
>    std::ostream& operator<<(std::ios_base& (__cdecl 
> *_Pfn)(std::ios_base&))
>                                            ^
> bin2.cxx: In member function ‘std::ostream& 
> BinStream::operator<<(std::ios_base&)’:
> bin2.cxx:46:16: error: ‘_Pfn’ was not declared in this scope
>     return os <<_Pfn;

I expect it's confused by __cdecl. I just copied the function 
declaration from VS' iostreams, so it might be tainted by how VS 
does things. Removing __cdecl might work, or just add
#define __cdecl __attribute__((__cdecl__))
A third option is to replace `std::ios_base& (__cdecl 
*Pfn)(std::ios_base&)` with `decltype(std::hex)& Pfn`.

All of this said, I'd suggest finding a C++ forum to get answers 
to these questions. While I'm happy to help, it's not really the 
place for these discussions.

--
   Biotronic


More information about the Digitalmars-d-learn mailing list