{
BOOST_CHECK_THROW( CpeId( "malformed" ), std::invalid_argument );
CpeId none( "malformed", CpeId::noThrow );
+ BOOST_CHECK_EQUAL( CpeId::NoThrowType::lastMalformed, "malformed" );
+ CpeId( "", CpeId::noThrow );
+ BOOST_CHECK_EQUAL( CpeId::NoThrowType::lastMalformed, "" );
for ( const auto & c : { CpeId(), CpeId( nullptr ), CpeId( "" ), CpeId( std::string() ) } )
{
// class CpeId
///////////////////////////////////////////////////////////////////
+ std::string CpeId::NoThrowType::lastMalformed;
+
CpeId::CpeId()
: _pimpl( new Impl )
{}
CpeId::CpeId( const std::string & cpe_r, NoThrowType )
{
try
- { _pimpl.reset( new Impl( cpe_r ) ); }
+ {
+ _pimpl.reset( new Impl( cpe_r ) );
+ NoThrowType::lastMalformed.clear();
+ }
catch(...)
- { _pimpl.reset( new Impl ); }
+ {
+ _pimpl.reset( new Impl );
+ NoThrowType::lastMalformed = cpe_r;
+ }
}
CpeId::~CpeId()
public:
/** Indicator type for non-trowing ctor. */
- struct NoThrowType {};
+ struct NoThrowType { static std::string lastMalformed; };
/** Indicator argument for non-trowing ctor. */
static constexpr NoThrowType noThrow = NoThrowType();