• 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
Conversion operator not being pickup by compiler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Conversion operator not being pickup by compiler


  • Subject: Conversion operator not being pickup by compiler
  • From: "Greg Norz" <email@hidden>
  • Date: Fri, 13 Jan 2006 12:55:33 -0600
  • Thread-topic: Conversion operator not being pickup by compiler

Below is a VERY contrived example of some code that's generating compiler warnings. We happen to turn on all warnings and treat them as errors, so the code HAS to be fixed. What happens is that a classes conversion operator is not being called (or at least the compiler can't figure it out) unless a static_cast is placed in front of the offending variable. Consider :
 
--- BEGIN ---
#include <iostream>
 
class Foo
{
public :
    explicit Foo( const char* message ) : m_str( message ) {}
 
    operator const char*() { return m_str.c_str(); }
private :
    std::string m_str;
};
 
greg norz
southwest airlines || southwest.com
email@hidden
 
Wright is Wrong! - www.setlovefree.com
 
 _______________________________________________
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: Conversion operator not being pickup by compiler
      • From: David Fang <email@hidden>
  • Prev by Date: Xcdoe and Class modeling
  • Next by Date: Conversion operator not being picked up by compiler
  • Previous by thread: Xcdoe and Class modeling
  • Next by thread: Re: Conversion operator not being pickup by compiler
  • Index(es):
    • Date
    • Thread