The do-while statement is defined the following way
do statement while ( expression ) ;
So between the do and while there can be any statement including the if statement.
As for your question
•What else can be put in between do and {?
According to the grammar after the do there must be a statement. So the only possibility that can look strange but is valid is to place a label. For example
do L1: { std::cout << "Hello do-while!" << std::endl; } while ( false );
because labeled statements also may be used.
For example the do-while statement from your post could look like
if(x.start()) do Come_Here: if(y.foo(x)) {
// Do things
}while(x.inc())
Take into account that you also may use an empty statement. In this case it will look like
do ; while ( false );
or
do Dummy:; while ( false );
And one more funny statement
do One: do Two: do Three:; while ( 0 ); while ( 0 ); while ( 0 );
Also in C++ declarations are also statements. So you may place a declaration between the do and while.
For example
int n = 10;
do int i = ( std::cout << --n, n ); while ( n );
In C declarations are not statements. So you may not place a declaration between the do and while in C.
And another funny example
#include<iostream>
#include <vector>
#include <stdexcept>
int main()
{
std::vector<int> v = { 1, 2, 3 };
size_t i = 0;
do try { std::cout << v.at( i ) << ' '; } catch ( const std::out_of_range & )
{ std::cout << std::endl; break; } while ( ++i );
return 0;
}
The program output is
1 2 3