2
boost :: regex_replace를 호출 할 때 사용자 지정 서식 함수를 호출하려면 어떻게해야합니까?사용자 지정 함수를 사용하는 방법, boost regex formatter
내 코드는 다음과 같습니다 :
template <typename T>
std::string fmt(boost::match_results<T> match) {
auto str = match[1];
if (str == ".") {
return "\".\"";
} else {
return str;
}
}
void __ConvertEscapeChar(std::string& action, std::string regex) {
boost::regex re(regex);
action = boost::regex_replace(action, re, &fmt, boost::regex_constants::match_all);
}
그러나 그것은 오류를 보여줍니다, "__fmt에 대한 템플릿 인수를 추론 할 수 없습니다". - T는 실제로 무엇입니까? 여기에 명확하지 않다 어떤 이유로 당신의
fmt
기능의 템플릿을 사용의 유연성을 필요로하지 않는
귀하의 함수 이름이 유효하지 않습니다. 참조 [여기] (http://stackoverflow.com/questions/228783/what-using-the-rules-about-using-an-underscore-in-ac-identifier) –
@ BenjaminLindley Meh 변경 ...하지만 그 dosen 정말 아무것도 바꿀 수 없습니다. (정말로 로컬 함수를 식별하는 새로운 PREfix가 필요합니다.) – paul23
현재 오류가 아닌 유효한 C++ 코드로 변경됩니다. –