[cfe-dev] __bridge and C++ references

James Gregurich bayoubengal at mac.com
Fri Apr 19 13:49:03 PDT 2013



I was working on the following snippet with ARC enabled. I expected the first function to complain about needing the __bridge keyword. It did not. I could get the __bridge keyword to be required as demonstrated in the second function. I suspect the rules are quite complete on the ARC checking. I thought I would bring this case to the attention of the list in case you wanted to tighten up those rules. cf_ptr is a subclass of std::unique_ptr<> that  is tailored for CoreFoundation types. It seems that the ARC __bridge doesn't get invoked there either. I expected casting this template to give me the __bridge error since it contains a data member of type NSString*.



            
            typedef strip_pointer<CFStringRef>::type CFString;
            #ifdef __OBJC__

        

            inline void copy(const NSString& theValue, std::string& theTarget)
            {
                copy( (const CFString&)theValue, theTarget);
            }
            
            inline void copy(const NSString& theValue, ustring& theTarget)
            {
                copy( *(__bridge  const CFStringRef) &theValue, theTarget);
            }

            inline void copy(const std::string& theValue, cf_ptr<NSString>& theTargetSPtr )
            {
                copy(theValue, (cf_ptr<CFString>&) theTargetSPtr);
            }
        
        
            inline void copy(const ustring& theValue, cf_ptr<NSString>& theTargetSPtr )
            {
                copy(theValue, (cf_ptr<CFString>&) theTargetSPtr);
            }
        
            
            #endif
            
            
            
            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130419/ba9f157c/attachment.html>


More information about the cfe-dev mailing list