I like more solution from #1837 :
 do {
      expansion_list->push_back(copy_locale);
      position = copy_locale.find_last_of("-");
      copy_locale = copy_locale.substr(0, position);
   } while (position != std::string::npos);