I have a few questions relating to combining Objective-C with C++0x (henceforth termed "Objective-C++0x") and specifics to how the two separate languages "mix" with each other. I'm not sure whether this or cocoa-dev is the best place to ask, but it's worth a shot here. I'm not particularly interested in debates about using one language over the other (or the paradigms of one language over the paradigms of the other), but I am interested in the pitfalls of trying to (ab)use both at the same time, in the hope of getting a better understanding of using Objective-C++ as a language unto itself rather than a "glue language", so to speak.
1. Is it possible to declare an Objective-C selector with the C++0x trailing return type? Something like this perhpas?
- (auto) doSomethingWith:(id) anObj -> id;
2. Is there a unified foreach loop that will work for both the C++ and Objective-C contexts, since both foreach loops have different syntaxes? Are the two interchangeable?
3. Is nil synonymous with 0 or nullptr? If I had foo(int) and foo(id), which one is called if foo(nil) is executed?
4. Are there plans to add an Objective-C++0x specific category to Cocoa foundation classes, or a C++ STL add-on to deal with Objective-C types? For example
+ (NSArray*) arrayWithTempSTLVector(std::vector<id>&& vector);
+ (NSArray*) arrayWithInitializerList:(std::initializer_list<id> items);
- (std::shared_ptr<NSArray>) sharedPtrFromSelf;
5. I've heard that while id is a typedef for objc_object*, you cannot use objc_object as a template parameter. Is this true? Am I really not allowed to do something like the constructions below? Can I treat Objective-C classes as if they are "derived classes" (in the C++ sense) from objc_object, which must be declared Objective-C style?
typedef boost::intrusive_ptr<objc_object> intrusive_id;
template <class ObjCClass>
HomogeneousNSArray<ObjCClass> : public boost::intrusive_ptr<NSArray> {
// which is implicitly an extension of intrusive_id
explicit operator std::vector<ObjCClass>() { /* ... */ }
};
HomogeneousNSArray<NSNumber> arrayOfNumbers;
6. Can a smart pointer to an Objective-C class (like boost::intrusive_ptr) use Objective-C property syntax? Without having to, say, subclass the smart pointer and insert a whole lot of "return get().property;"?
7. Is it possible to automatically convert between an Objective-C block and a C++ lambda expression?
8. Does constexpr work with Objective-C objects at all?
9. Do Objective-C classes still have to conform to the C++03 definition of POD, or can they be relaxed to the C++0x definition? Do C++ class members still have to be POD, or are they relaxed? (Just default-constructible? Just assignable? Fully-parameterized templates? Virtual inheritance? Virtual functions?)
I'd also like to know how well Objective-C mixes with C++03 as it is today, since I can't seem to find any documentation on this. Is there a place I can look? _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden