Boost logo

Boost :

Subject: Re: [boost] Implicit cast rules
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2011-05-24 10:35:16


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

On Tuesday, May 24, 2011, Gregory Crosswhite wrote:
> Hey everyone,
>
> Would someone please explain to me the implicit cast rule that prevents
> the following from compiling, and/or if there is a way around it?

It's standard behavior of static_cast 5.2.9 paragraph 2. If you did the
conversion implicitly instead of explicitly with static_cast, then the
boost::optional constructor that is causing you trouble would not be
considered (since it is explicit).

> I can tell what is happening; it would seem that the implicit cast rule
> selects the optional() constructor before it even looks at my more
> specific cast operator. I'm just confused about why this should be,
> since I see no reason why constructor casts should be prioritized over
> operator casts. Is this just the way it is, a GCC quirk, something I'm
> doing wrong, etc?

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

iEYEARECAAYFAk3bwiUACgkQ5vihyNWuA4Vw7QCgt+b7prO/646nZ5gaD8tQ4t9S
i2YAoIrtOzh3SkJwWCMxIUIc1s2a6HOh
=2mdf
-----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