What about this? It's pretty lightweight, and it should work just fine:
Code:
namespace detail_ {
struct implicit_bool
{
void implicit_true( void )
{ }
private:
implicit_bool( void );
};
}
typedef void ( detail_::implicit_bool::* implicit_bool )( void );
implicit_bool const
implicit_true = &detail_::implicit_bool::implicit_true,
implicit_false = 0;
struct test
{
test( void )
{ }
test( char const* )
{ }
operator implicit_bool( void )
{
return implicit_true;
}
friend test operator + ( test const&, test const& )
{
return test( );
}
};
int main( void )
{
test
a,
b = a + "foo";
if( b )
{
}
}