のフォーマット関数に問題がありますboost::regex_replace
。1つのパラメーターバージョンを呼び出すことはできますが、2つのパラメーターを呼び出すことはできません。
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;
}
上記は機能しますが、その静的変数を実際には使用したくないので、許容できる2つのパラメーターの代替バージョンであると思ったものを試しました。
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;
}
ただし、regex_replaceはこれを受け入れません(複雑なコンパイラエラー)。Boost::Regex
ドキュメントの以下に基づいて、2つのパラメータバージョンを使用しようとしています。
テンプレートbasic_stringregex_replace(const basic_string&s、const basic_regex&e、Formatter fmt、match_flag_type flags = match_default);
必須タイプフォーマッタは、関数呼び出しから置換文字列を計算する単項、バイナリ、または三項ファンクタのいずれかである必要があります。置換テキストとして使用されるchar_typeのコンテナを返す必要があるfmt(what)、またはfmtのいずれかです。 (what、out)またはfmt(what、out、flags)。どちらも置換テキストを* outに書き込み、新しいOutputIterator位置を返します。いずれの場合も、見つかった一致を表すmatch_resultsオブジェクトは何ですか。
コンパイラエラーメッセージの要求が繰り返されているので、ここにあります(要求する内容に注意してください)。
c:\ boost \ boost \ regex \ v4\regex_format.hppメンバー関数`OutputIterboost :: re_detail :: format_functor_container :: operator()(const Match&、OutputIter、boost :: regex_constants :: match_flag_type、const Traits&)[with OutputIter = boost :: re_detail :: string_out_iterator、std :: allocator >>、Container = const std :: string&(*)(const boost :: smatch&、std :: string&)、Match = boost :: match_results <__ gnu_cxx :: __normal_iterator、std :: allocator >>、std :: allocator、std :: allocator >> >> >>、Traits = boost :: regex_traits_wrapper >>]':
356 c:\ boost \ boost \ regex \ v4 \ match_results.hppは、 `OutputIterator boost :: match_results :: format(OutputIterator、Functor、boost :: regex_constants :: match_flag_type、const RegexT&)const [with OutputIterator = boost :: re_detail :: string_out_iterator、std :: allocator >>、Functor = const std :: string&(*)(const boost :: smatch&、std :: string&)、RegexT = boost :: basic_regex >>、BidiIterator = __gnu_cxx :: __ normal_iterator 、std :: allocator >>、Allocator = std :: allocator、std :: allocator >> >>] '
60 c:\ boost \ boost \ regex \ v4 \ regex_replace.hppは、 `OutputIterator boost :: regex_replace(OutputIterator、BidirectionIterator、BidirectionIterator、const boost :: basic_regex&、Formatter、boost :: regex_constants :: match_flag_type)[with OutputIterator boost :: re_detail :: string_out_iterator、std :: allocator >>、BidirectionIterator = __gnu_cxx :: __ normal_iterator、std :: allocator >>、traits = boost :: regex_traits>、charT = char、Formatter = const std :: string&(* )(const boost :: smatch&、std :: string&)] '
80 c:\ boost \ boost \ regex \ v4 \ regex_replace.hppは、 `std :: basic_string、std :: allocator <_T2>> boost :: regex_replace(const std :: basic_string、std :: allocator<_T2>>からインスタンス化されました&、const boost :: basic_regex&、Formatter、boost :: regex_constants :: match_flag_type)[with traits = boost :: regex_traits>、charT = char、Formatter = const std :: string&(*)(const boost :: smatch&、std ::ストリング&)]'
327 C:\ Dev-Cpp \ Examples \ wordrad\xhtml_open.cppはここからインスタンス化されます
1064 c:\ boost \ boost \ regex \ v4 \ regex_format.hppメンバーのリクエスト
begin' in
((boost :: re_detail :: format_functor_container、std :: allocator >>、std :: allocator、std :: allocator >> >> >>、 boost :: regex_traits_wrapper >>> *)this)-> boost :: re_detail :: format_functor_container、std :: allocator >>、std :: allocator、std :: allocator >> >> >>、boost :: regex_traits_wrapper >> >> :: func'、これは非クラスタイプ `const std :: string&(* const)(const boost :: smatch&、std :: string&)'1064 c:\ boost \ boost \ regex \ v4 \ regex_format.hppメンバーのリクエスト
end' in
((boost :: re_detail :: format_functor_container、std :: allocator >>、std :: allocator、std :: allocator >> >> >>、 boost :: regex_traits_wrapper >>> *)this)-> boost :: re_detail :: format_functor_container、std :: allocator >>、std :: allocator、std :: allocator >> >> >>、boost :: regex_traits_wrapper >> >> :: func'、これは非クラスタイプ `const std :: string&(* const)(const boost :: smatch&、std :: string&)'