Merge pull request #12915 from ctiller/flow++

C++ize flow control