configure: C++ compiler detection improvement