Boost logo

Boost :

From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2005-12-08 09:46:17


Stefan Seefeld wrote:
> Thorsten Ottosen wrote:
>
>>Hi All,
>>
>>I'm about to replace all my throw Foo; statetements in the Pointer
>>Container library with something else to support platforms without
>>exceptions.
>>
>>Is using boost::throw_exception the way to do it?
>>
>>If I where on such a platform, I kinda think that I would have preferred
>>an assertion *at the throw spot* instead of making the call stack deeper
>>yet and then call about or something.
>
>
> If it is not a throw expression it ought to be something with similar
> semantics, such as a function with __attribute__((__noreturn__)) (or
> whatever it is spelled for a particular compiler), so the compiler knows
> that no code past this point is ever executed.
> Else you may get spurious warnings about missing return statements.

is this necessary? after all, I think most function bodies would look like

{
   if( foo() )
        boost::throw_exception( ... )
   ...
   // normal code here
}

Anyway, my feeling is that people that uses BOOST_NO_EXCEPTION would prefer

if( foo() )
  BOOST_THROW_EXCEPTION( std::exception, "MSG" );

where this expands to BOOST_ASSERT( "MSG" ) when BOOST_NO_EXCEPTION is true.

Has anybody that work in an environment without exceptions got any opinions?

-Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk