help-source-highlight
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-source-highlight] Re: [regex] bad_expression changed interface


From: Lorenzo Bettini
Subject: [Help-source-highlight] Re: [regex] bad_expression changed interface
Date: Wed, 17 Aug 2005 10:32:44 +0200
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050727)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]