[cfe-dev] Specializing templates on Objective-C ARC ownership annotations

Louis Dionne via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 31 15:14:02 PDT 2018


I'm trying to partially specialize a template on ARC-annotated pointer types, and I'm finding it doesn't work. Specifically, the following fails because the "specialization" for `T __strong*` is never considered, and we always fall back to the specialization for `T*`:

    // clang test.mm -fobjc-arc -ObjC++ -std=c++14

    #import <Foundation/NSObject.h>

    @interface Foo: NSObject
    { }
    @end

    template <typename T> struct Specialize;
    template <typename T> struct Specialize<T*> { static constexpr bool value = false; };
    template <typename T> struct Specialize<T __strong*> { static constexpr bool value = true; };
    static_assert(Specialize<Foo __strong*>::value, "");

    int main() { }

I have a few questions:

- Does this even make sense? I don't know much of Objective-C, so it's possible that treating ownership qualifiers like cv qualifiers is not even sensical.
- If it does make sense, why is it not supported? Is this simply a bug that needs fixing?

Strangely enough, I haven't found anything online regarding this, so I'm turning to this list as a last resort.

Thanks,
Louis



More information about the cfe-dev mailing list