unhandled exception (assertion) in Boost.Regexp regex_formatter with VS2005

Hi. I am a relative newbie to two things: - Boost C++ libraries - Working with the standard C++ libraries and this is my first post on this list. Hello to everyone - I hope you'll forgive me if following question is simply stupid. I cant't even tell that. I currently need to wrap some of the functionality string algorithms and Boost.Regexp offers in Windows DLLs; the developemnt environment I use is VS2005. I started with the samples given in string algorithms which offer a different interface to some of the Boost.Regexp library. I slightly modified the sample and basically now have something like this: using namespace std; using namespace boost; string strInput ("abc__(456)__123__(123)__cde"); regex expression = "[0-9]+" string strReplaceWith("#$1#") string strResult = replace_all_regex_copy(str, expression, strReplaceWith ); This certainly does not make that much sense; its however user input I need to cope with and my problem is that I get an unhandled exception here which I cannot catch. Failure is exactly here (regex_format.hpp): template <class OutputIterator, class Results, class traits> void basic_regex_formatter<OutputIterator, Results, traits>::put(const sub_match_type& sub) { typedef typename sub_match_type::iterator iterator_type; iterator_type i = sub.first; while(i != sub.second) { put(*i); ++i; } } in the line "while(i != sub.second)" I saw that the MS standard C++ libraries compares the iterator types here. And, maybe because in my sample both - i and sub.second - are NULL here, it asserts with "string iterators incompatible". Does anybody know how to solve this problem ? Am I doing something completely wrong or is this maybe a incompatibility of Boost C++ with the MS standard C++ library and other compilers would behave different for my sample ? Any help or insight greatly appreciated. Andreas.

Andreas Sedlmeier schrieb:
I currently need to wrap some of the functionality string algorithms and Boost.Regexp offers in Windows DLLs; the developemnt environment I use is VS2005. [...]
Failure is exactly here (regex_format.hpp): template <class OutputIterator, class Results, class traits> void basic_regex_formatter<OutputIterator, Results, traits>::put(const sub_match_type& sub) { typedef typename sub_match_type::iterator iterator_type; iterator_type i = sub.first; while(i != sub.second) { put(*i); ++i; } }
in the line "while(i != sub.second)"
Are you already creating a DLL and using it from an application? If yes, then you need to be very careful. If your DLL interface contains C++ objects (and is not just a plain C interface), then the DLL must be compiled with exactly the same compiler switches and project defines as the application. You can not run a DEBUG DLL with the release version of the application. YOu can not use the release DLL with the debug version of the application. You can not statically link the C/C++ runtime library to the DLL and use the DLL version of the runtime lib with the APP. Both modules must have the same settings for interator debugging. I guess you are having a windows DLL problem, not a boost problem. Tell us more about your project setup, maybe we can help then. Norbert Unterberg
participants (2)
-
Andreas Sedlmeier
-
Norbert Unterberg