My application is on Boost version 1.46.1. I want to port my application on Boost version 1.58.0. However I am facing some problems.
I have noticed that boost 1.58 has different implementation of boost::exception_ptr
from 1.46.1. In 1.46.1, boost::exception_ptr
was implemented as shared pointer:
typedef shared_ptr<exception_detail::clone_base const> exception_ptr;
where as in 1.58 all the implementation was encapsulated inside a class.
class exception_ptr {
typedef boost::shared_ptr<exception_detail::clone_base const> impl;
impl ptr_;
friend void rethrow_exception(exception_ptr const &);
typedef exception_detail::clone_base const *(impl::*unspecified_bool_type)() const;
public:
exception_ptr() {}
explicit exception_ptr(impl const &ptr) : ptr_(ptr) {}
bool operator==(exception_ptr const &other) const { return ptr_ == other.ptr_; }
bool operator!=(exception_ptr const &other) const { return ptr_ != other.ptr_; }
operator unspecified_bool_type() const { return ptr_ ? &impl::get : 0; }
};
Due to this changes my code is breaking... :(
boost::exception_ptr ExceptionHelper::GetExceptionPtr(MyExceptionPtr_t exception) {
boost::exception_ptr result =
boost::dynamic_pointer_cast<boost::exception_detail::clone_base const>(exception); // This is giving build error
return result;
}
MyExceptionPtr_t ExceptionHelper::TryGetMyExceptionPtr(boost::exception_ptr exception) {
MyExceptionPtr_t result;
boost::shared_ptr<const Exception> constPtr =
boost::dynamic_pointer_cast<const Exception>(exception); // This is giving build error.
if (constPtr) {
result = boost::const_pointer_cast<Exception>(constPtr);
}
return result;
}
std::string ExceptionHelper::GetThrowFilename(const boost::exception_ptr exception) {
std::string result;
if (exception) {
if (boost::get_error_info<boost::throw_file>(*exception)) // This is giving build error.
{
result = *boost::get_error_info<boost::throw_file>(*exception);
}
}
return result;
}
Could you please suggest me, how to fix the above errors ??
Thanks