port dlgprs utility to C++ STL for better portability