[regex] bad_expression changed interface

Hi in 1.31 bad_expression was class bad_expression : public bad_pattern { public: bad_expression(const std::string& s) : bad_pattern(s) {} }; now in 1.33 it is class regex_error : public std::runtime_error { public: explicit regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos); explicit regex_error(boost::regex_constants::error_type err); boost::regex_constants::error_type code()const; std::ptrdiff_t position()const; }; typedef regex_error bad_pattern; // for backwards compatibility typedef regex_error bad_expression; // for backwards compatibility so I was wondering if there's a way to make throw boost::bad_expression("internal error"); compile on both versions of the library (this statement was reported not to compile with 1.33 by a user of one of my programs) many thanks in advance Lorenzo -- +-----------------------------------------------------+ | Lorenzo Bettini ICQ# lbetto, 16080134 | | PhD in Computer Science | | Dip. Sistemi e Informatica, Univ. di Firenze | | Florence - Italy (GNU/Linux User # 158233) | | Home Page : http://www.lorenzobettini.it | | http://music.dsi.unifi.it XKlaim language | | http://www.lorenzobettini.it/purple Cover Band | | http://www.gnu.org/software/src-highlite | | http://www.gnu.org/software/gengetopt | | http://www.lorenzobettini.it/software/gengen | | http://www.lorenzobettini.it/software/doublecpp | +-----------------------------------------------------+

now in 1.33 it is
class regex_error : public std::runtime_error { public: explicit regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos); explicit regex_error(boost::regex_constants::error_type err); boost::regex_constants::error_type code()const; std::ptrdiff_t position()const; };
typedef regex_error bad_pattern; // for backwards compatibility typedef regex_error bad_expression; // for backwards compatibility
so I was wondering if there's a way to make
throw boost::bad_expression("internal error");
compile on both versions of the library (this statement was reported not to compile with 1.33 by a user of one of my programs)
many thanks in advance
I must admit I hadn't anticipated that folks would be throwing objects of that type (just catching them), the only fix is to change the constructor to: explicit regex_error(const std::string& s, regex_constants::error_type err = 0, std::ptrdiff_t pos = 0); Otherwise to change your code to add the extra parameters. I'll add this to the list of things to fix. John.

John Maddock wrote:
now in 1.33 it is
class regex_error : public std::runtime_error { public: explicit regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos); explicit regex_error(boost::regex_constants::error_type err); boost::regex_constants::error_type code()const; std::ptrdiff_t position()const; };
typedef regex_error bad_pattern; // for backwards compatibility typedef regex_error bad_expression; // for backwards compatibility
so I was wondering if there's a way to make
throw boost::bad_expression("internal error");
compile on both versions of the library (this statement was reported not to compile with 1.33 by a user of one of my programs)
many thanks in advance
I must admit I hadn't anticipated that folks would be throwing objects of that type (just catching them), the only fix is to change the constructor to:
explicit regex_error(const std::string& s, regex_constants::error_type err = 0, std::ptrdiff_t pos = 0);
that's exactly what I had in mind
Otherwise to change your code to add the extra parameters.
but my code should be compiled with both versions of the library (and from what I see, in 1.31 only the string constructor is accepted), that's the problem... so probably I should add a test to the configure script and an #ifdef statement to throw the exact exception
I'll add this to the list of things to fix.
thanks Lorenzo
participants (2)
-
John Maddock
-
Lorenzo Bettini