Operator overloading in Cartography and Rhea

28 views
Skip to first unread message

Håvard Fossli

unread,
Sep 24, 2014, 5:24:23 AM9/24/14
to overcon...@googlegroups.com
Using operator overloading in Swift and C++ it is possible to write constraints in a very natural manner.

layout(view1, view2) { view1, view2 in
    view1
.width   == (view.superview!.width - 50) * 0.5
    view2
.width   == view1.width - 50
    view1
.height  == 40
    view2
.height  == view1.height
    view1
.centerX == view.superview!.centerX
    view2
.centerX == view1.centerX


    view1
.top >= view.superview!.top + 20
    view2
.top == view1.bottom + 20
}

Check out Cartography for Swift

And Rhea for C++
Reply all
Reply to author
Forward
0 new messages