Are there a kind of AnyStruct or ~AnyClass?

I want to implement a generic DTO cache for values types where I can use the owner ship model to improve performance / avoid retain-release circles, but I think there is no AnyStruct - Type or similar to enforce it.

There's no way to express this kind of constraint today, because you can always just do this:

struct Wrapper {
  var x: AnyObject
}

The compiler has no way to reason about how you're going to use 'x'.

Well, there's BitwiseCopyable, which excludes class instances, and a whole host of other types too.

3 Likes

But not UnsafeMutablePointers.