• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: gcc 4 const confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc 4 const confusion


  • Subject: Re: gcc 4 const confusion
  • From: Alexey Proskuryakov <email@hidden>
  • Date: Mon, 30 May 2005 11:32:20 +0400

On 28.05.2005 04:16, "Scott Lahteine" <email@hidden> wrote:

>      virtual void InsertCopyBefore(UInt16 index, const T** elemPtr,
> UInt16 count=1)
<...>
>      inline void InsertCopyBefore(UInt16 index, const TObjectArray<T>
> &src) { InsertCopyBefore(index, src.m_array, src.Size()); }
>
>
> The last method is the one that gets the error in gcc4:
>
> TArray.h:418: error: invalid conversion from 'FPChordGroup** const'
> to 'const FPChordGroup**'
> TArray.h:418: error:   initializing argument 2 of 'void
> TObjectArray<T>::InsertCopyBefore(UInt16, const T**, UInt16) [with T
> = FPChordGroup]'
>
>
> But I'm probably misunderstanding the concept of constness in some way.

  The issue here is that a pointer to a const object is different from a
const pointer to an object (or from a const pointer to a const object). You
are trying to pass a const pointer as a pointer to a const object, and the
compiler rightfully complains.

> What changes can I make to my code so that this error won't occur and
> yet maintain the const-ness of that argument?

  Without knowing more about the architecture of your application, I'd say
that the best approach would be to use STL rather than a custom container. A
few days ago, the options were discussed on this list (search for a message
from Howard Hinnant).

  As an immediate fix, you may try to declare m_array mutable.

- WBR, Alexey Proskuryakov


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: gcc 4 const confusion
      • From: David Leimbach <email@hidden>
References: 
 >gcc 4 const confusion (From: Scott Lahteine <email@hidden>)

  • Prev by Date: RE: locale.h file missing
  • Next by Date: Relocation entries in non-writable section
  • Previous by thread: gcc 4 const confusion
  • Next by thread: Re: gcc 4 const confusion
  • Index(es):
    • Date
    • Thread