On Tue, 03 Dec 2002 20:55:02 -0500, David Abrahams
<[EMAIL PROTECTED]> wrote:

>
>I'd like a macro to detect that a compiler requires a return value
>even when no paths return from a function. Example:
>
>    int f()
>    {
>        throw "hello";
>    };
>
>If this fails to compile, we may need to add a dummy "return 0;" at
>the end.

I'm a little surprised by this question. Are you saying that *no*
paths return a value and you declare the function as non void?

Maybe you were referring to a situation like this?


  // The throw is conditional, and there's at
  // least one path that does return a value
  //
  template <typename ExceptionT>
  void do_throw(ExceptionT const & ex) { throw ex; }


  int f() {
    for ( ...)
      if  (...)
        return somevalue;

    do_throw( some_exception() );
  }


Genny.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to