Hi Team,
While doing typecasting from boost::any to DecodeErrorPayload_t, its throwing bad_any_cast ..
class RegisterIONotification
{
public:
enum NotifyType {
TypeUnknown,
TypeRegTx,
TypeRegRx,
TypeDecodeError
};
NotifyType Type;
boost::any Payload;
typedef boost::tuple DecodeErrorPayload_t;
RegisterIONotification(NotifyType type;,boost::any payload)
{
Type(type);
Payload(payload);
}
};
I have called RegisterIONotification from other class function.
void RegisterIOThreaded::OnDecodeError( const std::string& error, BinaryBuffer_t data )
{
RegisterIONotification notify(RegisterIONotification::TypeDecodeError ,make_tuple(error, data));
.....
....
...
}
While testing, I am getting bad_any_cast exception.
TEST_F(...,...)
{
RegisterIONotification notify = sink.GetDataById(ID::NOTIFY_COMMS_STATUS, 0).GetValue<RegisterIONotification>();
ASSERT_EQ(RegisterIONotification::TypeDecodeError, notify.Type); //passed
RegisterIONotification::DecodeErrorPayload_t payload;
ASSERT_NO_THROW(payload = boost::any_castRegisterIONotification::DecodeErrorPayload_t(notify.Payload));// Here its got failed...Please help me to fix this.
}
Regards,
Rajesh D
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.