• 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: gcc4.0, char_traits termplate specialization error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc4.0, char_traits termplate specialization error


  • Subject: Re: gcc4.0, char_traits termplate specialization error
  • From: Howard Hinnant <email@hidden>
  • Date: Thu, 9 Feb 2006 17:24:01 -0800

On Feb 9, 2006, at 2:15 PM, Alex Sheh wrote:

This isn’t an Xcode questions per se, but I was wondering if anyone has seen the below problem. I also posted to gcc-help and libstdc+ + lists, but no responses. Thanks!

I recently updated my system from gcc 3.3. to 4.0 (Panther to Tiger), and now I am getting a template error. For the below code, I get the “error: no member function assign declared in std:::char_traits<myChar>”.

typedef std::char_traits<myChar> myTraits; // Interestingly, if I change this to __gnu_cxx::char_traits
// then it compiles, but I’m not sure if this is correct/acceptable
template <> void myTraits::assign(myChar& lhs, myChar const& rhs)
{
// definition
}


I looked in char_traits.h and saw that there is a new namepsace __gnu_cxx, with a base struct of the same name as the derived struct in std namespace. I also came across an libstdc++ archived posting about __gnu_cxx’s char_traits masking the one in std, not sure if this is related to the error I’m getting. Does changing the typedef to __gnu_cxx::char_traits effectivlely achieve what the previous line of code (std::char_traits) was doing? Thanks for your help.

Hi Alex,

The standard doesn't promise that this will work. If myChar is a typedef for a built-in type (unsigned short is a popular choice), the standard outright forbids this type of specialization for any std template. If myChar is a struct/class, the standard again (more weakly) forbids it because the primary char_traits template is not promised to exist beyond a simple forward declaration, nor has any specification (such as a member function assign).

That being said, I can sympathize with your use case, and having the std::lib support such code as an extension is not an unreasonable request. To answer your final question, yes referring to __gnu_cxx::char_traits instead should get you up and running.

-Howard


_______________________________________________ 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: gcc4.0, char_traits termplate specialization error
      • From: Steve Checkoway <email@hidden>
References: 
 >gcc4.0, char_traits termplate specialization error (From: "Alex Sheh" <email@hidden>)

  • Prev by Date: Re: OT: Applescript help
  • Next by Date: Re: OT: Applescript help
  • Previous by thread: gcc4.0, char_traits termplate specialization error
  • Next by thread: Re: gcc4.0, char_traits termplate specialization error
  • Index(es):
    • Date
    • Thread