Boost logo

Boost :

From: Sid Sacek (ssacek_at_[hidden])
Date: 2007-11-10 07:28:28


Microsoft compiler doesn't fully support "Exception Specifications". The details are below. If you use this feature, it will not be
portable code.
-Sid Sacek

This is from MSDN:

ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vclang/html/4d3276df-6f31-4c7f-8cab-b9d2d003a629.htm

Visual C++ departs from the ANSI Standard in its implementation of exception specifications. The following table summarizes the
Visual C++ implementation of exception specifications:

Exception specification Meaning
throw()
 The function does not throw an exception. However, if an exception is thrown out of a function marked throw(), the Visual C++
compiler will not call unexpected (see unexpected (CRT) and unexpected (<exception>) for more information). If a function is marked
with throw(), the Visual C++ compiler will assume that the function does not throw C++ exceptions and generated code accordingly.
Due to code optimizations that maybe performed by the C++ compiler (based on the assumption that the function does not throw any C++
exceptions) if function does throw an exception, the program may not execute correctly.
 
throw(...)
 The function can throw an exception.
 
throw(type)
 The function can throw an exception of type type. However, in Visual C++ .NET, this is interpreted as throw(...). See Function
Exception Specifiers.

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Sergey Shandar
Sent: Saturday, November 10, 2007 7:19 AM
To: boost_at_[hidden]
Subject: Re: [boost] Is there any interest in a casting library where you don't need to specify a type of receiver?

shunsuke wrote:
> Sergey Shandar wrote:
>
>> 3. I found this one today:
>>
>> template<class T>
>> operator T &() const
>> throw(typename ::boost::disable_if< ::boost::is_same<T, MyClass
>> const> >::type *)
>>
>
> You've solved the millenium problem! :-)
>
> gcc3.4.5 and 4.1.2 seem to work fine.
> Thanks!
>
>
Right, here is the new problem: If you specify at least one throw type
(we do) then you have to specify all possible exceptions for the function!

    template<class T>
    operator T &() const
        throw(typename ::boost::disable_if< ::boost::is_same<T, MyClass const> >::type *)
        throw(::std::exception)
        throw(::MyLibrary::exception)
        throw( what else? )

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


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