boost::regex_replace
'daki biçim işleviyle ilgili sorun yaşıyorum. Bundan bir parametre versiyonunu değil, iki parametreyi arayabilirsiniz:İki parametre biçimi işleviyle ilgili sorunlar boost :: regex_replace
e = "(^|>)([^<>]+)";
h_str = regex_replace(h_str, e, repl_quot, boost::match_default);
repl_quot
std::string const &repl_quot(boost::smatch const &what) {
boost::regex e("\"");
std::string repl(""");
static std::string;
str = regex_replace(what[0].str(), e, repl, boost::match_default);
return str;
}
yukarıdaki eserleri olarak tanımlanır, ama gerçekten bu statik kullanmak istemiyoruz
std::string const &repl_quot2(boost::smatch const &what, std::string &out) {
boost::regex e("\"");
std::string repl(""");
out = regex_replace(what[0].str(), e, repl, boost::match_default);
return out;
}
Ama bu (bir dolambaçlı derleyici hatası) regex_replace kabul etmeyecektir: değişken, bu yüzden ben kabul edilebilir bir iki parametre alternatif sürümü olduğunu düşündüğü şeyi denedik. Ben Boost::Regex
belgelerinden aşağıdakilere dayalı iki parametre sürümünü kullanmaya çalışıyorum:
şablon basic_string regex_replace (const & s basic_string, const & e basic_regex, Formatter bicim, match_flag_type bayrakları = match_default);
tip Formatter olmalıdır gerektirir ya ... bir işlev çağrısından yedek dize hesaplar bir, tekli ikili veya üçlü funktor: char_type en bir kabı dönmelidir hangi olmaya (ne) fmt ya yeni OutputIterator pozisyonu geri sonra yeni metni için * yazmak ve her ikisi de yedek metni veya ya fmt (ne dışarı) ya da fmt (dışarı ne , bayrakları) olarak kullandı. Her durumda temsil eden match_results nesnesi eşleşmeyi buldu.
, işte derleyici hata iletisi için tekrarlanan istekleri olmuştur öyle (dikkatli olmak ne isteyebilir):
c: \ boost \ boost \ regex \ v4 \ regex_format.hpp Üye işlevinde `OutputIter boost :: re_detail :: format_functor_container :: operator() (const Eşleşme &, OutputIter, boost :: regex_constants :: match_flag_type, const Özellikleri &) [OutputIter ile = boost :: re_detail :: string_out_iterator, std: : ayırıcı>>, Container = const std :: string & (*) (const güçlendirme :: smt &, std :: string &), Eşleşme = Artırmak :: < __gnu_cxx :: __ normal_iterator std :: ayırıcısı>>, std :: ayırıcısı, std :: ayırıcısı>>>>>, Soylar> regex_traits_wrapper = boost ::>] match_results:
356 c : \ boost \ boost \ regex \ v4 \ match_results.hpp, OutputIterator boost :: match_results :: biçiminden çıktılandı (OutputIterator, Functor, boost :: regex_constants :: match_flag_type, const RegexT &) const [OutputIterator = destekle birlikte :: re_detail :: string_out_iterator, std :: allocator>>, Functor = const std :: dize & (*) (const boost :: smatch &, std :: dize &), RegexT = boost :: basic_regex>>, BidiIterator = __gnu_cxx :: __ normal_iterator, std :: ayırıcı>>, Allocator = std :: ayırıcısı, std :: ayırıcısı>>>>]
60 c: artırmak OutputIterator `den örneği \ takviye \ artırmak \ normal ifade \ v4 \ regex_replace.hpp :: regex_replace (OutputIterator, BidirectionalIterator, BidirectionalIterator const boost :: basic_regex &, Biçimlendirme, güçlendirme :: regex_constants :: match_flag_type) [OutputIter ile ator = boost :: re_detail :: string_out_iterator, std :: ayırıcı>>, BidirectionalIterator = __gnu_cxx :: __ normal_iterator, std :: ayırıcı>>, traits = boost :: regex_traits>, charT = char, Biçemleyici = const std :: string & (*) (const boost :: smatch &, std :: string &)]'
80 c: std :: basic_string, std' örneklenen \ takviye \ artırmak \ normal ifade \ v4 \ regex_replace.hpp :: allocator < _T2>> boost :: regex_replace (const std :: basic_string, std :: ayırıcı < _T2>> &, const desteği :: basic_regex &, Biçimlendirici, destek :: regex_constants :: match_flag_type) [özelliklerle = destekle :: regex_traits>, charT = char, Biçimlendirici = const std :: dize & (*) (const boost :: smatch &, std :: string &)]'
327 ° C Dev-CPP \ Örnekler \ wordrad \ xhtml_open.cpp burada
1064 c örneği \: \ takviye \ artırmak \ normal ifade \ v4 \ regex_format. üye için hpp isteği
begin' in
((boost :: re_detail :: format_functor_container, std :: allocator>>, std :: ayırıcı, std :: ayırıcı>>>> yükselt, :: regex_traits_wrapper>>> *) this) -> boost :: re_detail :: format_functor_container, std :: ayırıcı>>, std :: allocator, std :: allocator>>>>>, boost :: regex_traits_wrapper>>> :: func ', sınıf dışı bir türdür const std :: string & (* const) (const güçlendirme :: smil &, standart: dize &) '1064 c: \ boost \ boost \ regex \ v4 \ regex_format.hpp üye
end' in
isteği (boost :: re_detail :: format_functor_container, std :: allocator>>, std :: allocator, std :: allocator> >>>>, boost :: regex_traits_wrapper>>> *) this) -> boost :: re_detail :: format_functor_container, std :: ayırıcı>>, std :: ayırıcı, std :: ayırıcı>>>>>, artırın: : regex_traits_wrapper>>> :: fonk 'olmayan sınıf türü olan `const std :: string & (* const) (const boost :: smatch &, std :: string &)'
Aldığınız hatayı postalamalısınız. –
Çok uzun sürüyor. Başlarını veya kuyruklarını yapamayacağımı tahmin ediyorum. Onun şablonu ile ilgili veya bir şey. Sorun, regex-replace'in fmt parametresi için bir imza, şablonlara ya da her neyse, bir imza olarak beklemesidir. Bu hata mesajı kabul edilemez. – Mark
1064 c: \ boost \ boost \ regex \ v4 \ regex_format.hpp üye 'son' isteğinde '' ((boost :: re_detail :: format_functor_container, std :: allocator >>, std :: allocator , std :: ayırıcı >>>> boost :: regex_traits_wrapper >>> *) this) -> boost :: re_detail :: format_fu ... –
Mark