public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gokhan Kisacikoglu <kisa@centropolisfx.com>
To: Dave Williss <dwilliss@microimages.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How do I avoid this warning?
Date: Thu, 18 Jul 2002 16:14:00 -0000	[thread overview]
Message-ID: <3D374C3C.57ACBD01@centropolisfx.com> (raw)
In-Reply-To: <092001c22e6b$fa635f30$2200000a@opus800>

Dave Williss wrote:
> 
> I get a lot of warnings of the type:
> 
>     warning: choosing `FOO::operator BAR*()` over `FOO::operator const
> BAR*()
>         for conversion from FRED to const BAR*
>         because conversion sequence for the argument is better
> 

Who is FRED? I guess you meant FOO! ;)

* Anyway, I guess the following would work better;

FOO::operator BAR*()			// non-const cases
FOO::operator const BAR*() const 	// for const cases

This will always use BAR * if FOO is not const, and const BAR * whenever
FOO is const. This is at least more consistent...

* If you need to do explicitely convert to const BAR * from a non-const
FOO, then maybe you should have an explicit method for that;

const BAR * FOO::asBAR() const

FOO *f = new FOO;
const BAR *constb = f->asBar();
BAR *b = f;	// guaranteed to return BAR * in this context

BTW, if your destructors are properly defined as virtual, then deleting
a BAR * should never be a problem...

HTH,
Gokhan

  reply	other threads:[~2002-07-18 23:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-18  8:01 Dave Williss
2002-07-18 16:14 ` Gokhan Kisacikoglu [this message]
2002-07-19  8:22   ` Dave Williss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D374C3C.57ACBD01@centropolisfx.com \
    --to=kisa@centropolisfx.com \
    --cc=dwilliss@microimages.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).