Swift Constraints to C++

I love the constraints / anchors in Swift and am working on a C++ project which I want to write my own library that has the same functionality that the Swift constraints have.

I've dived as deep as I can go into the source files and haven't found what I thought I might find. Generally, from my experience when I deal with graphics programming, I find the typical X, Y, Width, Height coordinates buried and thought the constraints would show something of the like when having a look. I couldn't find anything like that, only the NSLayoutYAxis, NSLayoutXAxis, NSLayoutAnchor with all the top, bottom, leading, trailing etc.

I was wondering if anyone has done something similar? Is there a bunch of the Apple source code relating to this that is hidden away?

Thanks in advance

Yes. There are no constraints/anchors in Swift (well, not those kinds anyway). They are a feature of the Apple UI frameworks, and thus closed source and kind of off topic here.

I'll nevertheless mention they are (or at least were, if memory serves) based on the Cassowary Constraint Solving Toolkit, about which you can find more information here and here.

Ahh ok. Well thanks for providing those links, I'll check them out.

FWIW, Apple appears to have abandoned this system in favour of SwiftUI’s simpler, more predictable layout system. Constraints sound like a good system in theory, but in practice they can be slow and give unpredictable results.

See this article: https://kean.github.io/post/swiftui-layout-system