throw list

Hi programmers))

// A.h

class A
{
.....
public:
void remove(int)
throw(MyExcept);
.....
};

// A.cpp

void A::remove(int pos)
throw(MyExcept)
{
...
}

GNU compiler requires throw list
void A::remove(int pos)// error
{
...
}

but in visual studio it's not an error

who can explain why? which one is more logical?


Last edited on
Visual Studio doesn't implement throw specifications: http://msdn.microsoft.com/en-us/library/wfa0edys(v=vs.110).aspx
So it doesn't give an error.
thanks
The use of dynamic-exception-speciļ¬cations is deprecated. - IS

Instead:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct A
{
    void foo() noexcept ; // will never throw

    void bar() ; // may throw

    // will never throw if default constructor of B will never throw
    // may thow otherwise
    A() noexcept( std::is_nothrow_default_constructible<B>::value ) ;
    
    // ...

    B b ;
};
Topic archived. No new replies allowed.