
Hi there, I am using in-place replacement with replace_all_regex replace_all_regex( source, boost::regex("(%f)"), "(?1 xxx)", format_all); where source is of type std::string. But for some reason, I need to perform replacement on a C-string (char *), is replace_all_regex safe to do so? Will replace_all_regex handle memory issue for us? Thanks.

On 8/1/06, llwaeva@21cn.com
But for some reason, I need to perform replacement on a C-string (char *), is replace_all_regex safe to do so? Will replace_all_regex handle memory issue for us?
Of course this would be impossible. Boost.Regex can't know how the memory was allocated (e.g. malloc or new or some custom allocator), or even if it *was* allocated. Why do you need to operate on raw char*'s? Why can't you operate on an std::string? -- Caleb Epstein

llwaeva@21cn.com wrote:
Hi there, I am using in-place replacement with replace_all_regex
replace_all_regex( source, boost::regex("(%f)"), "(?1 xxx)", format_all);
where source is of type std::string. But for some reason, I need to perform replacement on a C-string (char *), is replace_all_regex safe to do so? Will replace_all_regex handle memory issue for us?
You cannot do this, since char* is not a sequence. In other words, it cannot be safely constructed. Regards, Pavol
participants (3)
-
Caleb Epstein
-
llwaeva@21cn.com
-
Pavol Droba