Added template function select_if() in variant.h; Unit-tested.

not a big deal, but always prefer `++record_idx` over `record_idx++` for performance reasons.