Topic: operator void


Author: Hyman Rosen <hymie@prolifics.com>
Date: 2000/03/09
Raw View
"Andrei Alexandrescu" <andrewalex@hotmail.com> writes:
> 12.3.2/1 says I can do this:
> struct Foo
> {
>     operator void();
> };
> If I can, how can I invoke this operator? I know of only one way:
> Foo bar;
> bar.operator void();

12.3.2/1 also says explicitly that conversion operators are never used
for conversion to void, so this is the only way.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Andrei Alexandrescu" <andrewalex@hotmail.com>
Date: 2000/03/08
Raw View
12.3.2/1 says I can do this:

struct Foo
{
    operator void();
};

If I can, how can I invoke this operator? I know of only one way:

Foo bar;
bar.operator void();

I tried:

(void)bar;

MWCW didn't invoke it. I tried:

static_cast<void>(bar);

Again, MWCW didn't invoke it.

Please, could someone tell me what should be the correct behavior?


Andrei




---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]