Code dedup Grappa/C++ backends

Grappa currently uses identical implementations of operators like select.