Boost logo

Boost :

Subject: Re: [boost] [type traits extension] test for const volatile& as return type
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-07-08 02:26:52


On Thu, Jul 7, 2011 at 9:41 PM, Adam Merz <adammerz_at_[hidden]> wrote:

> Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung <at> gmail.com> writes:
> > <snip>
> > What is a "standard conversion sequence"?
>
> It's one of three classifications of conversion sequences; it would take
> copy/pasting most of §13.3.3.1 to define fully. The important part is that
> it's
> a better overload candidate than an ellipsis conversion sequence.
>

Well arguably just as important is that there *is* a standard conversion
sequence from an int to int const volatile &.

Just to confirm, on MSVC9, the following compiles:

int f(int const volatile &);
//void f(...); // *
int g();

int main(int argc, char* argv[])
{ sizeof(f(g())); }

...but if you uncomment line *,

error C2070: 'void': illegal sizeof operand

So, right, MSVC (and, evidently, GCC) are preferring the (...) overload to
(int const volatile &), even though the (int const volatile &) can
legitimately be bound to the int rvalue. Maybe some compiler workarounds
will have to introduced into these extended type traits to deal with const
volatile & return types...

> [ I don't have a copy of the standard; if it's freely available on the
> > internet somewhere, freely point me in the right direction :) ]
>
> It's ~$450 USD from the ISO committee if I recall correctly, but I can't
> imagine
> it would be that hard to find...
>

Yes, this is what I remember running into some time ago; a google search now
directed me to Herb Sutter's blog, which directed me to the ANSI page
selling the pdf for $30, which is (almost) free relative to $450 (and within
my student budget). But now with C++0x available on the horizon...

- Jeff


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