where do exception specifications go?

Discussion in 'C++' started by ab2305@gmail.com, Oct 4, 2005.

  1. Guest

    according to standard it should be part of the declation


    class A{

    T somefunc()throw (SomeException);
    };

    yet I found it useful when it is also part of the definition

    template<typename T>
    T A<T>::someFunc()throw(SomeException){}

    what is the usual style?
     
    , Oct 4, 2005
    #1
    1. Advertising

  2. Ian Guest

    wrote:
    > according to standard it should be part of the declation
    >
    >
    > class A{
    >
    > T somefunc()throw (SomeException);
    > };
    >
    > yet I found it useful when it is also part of the definition
    >
    > template<typename T>
    > T A<T>::someFunc()throw(SomeException){}
    >
    > what is the usual style?
    >

    Yes, they are required in both declaration and definition. But in most
    cases they are more trouble than they are worth.

    Ian
     
    Ian, Oct 4, 2005
    #2
    1. Advertising

  3. Greg Guest

    wrote:
    > according to standard it should be part of the declation
    >
    >
    > class A{
    >
    > T somefunc()throw (SomeException);
    > };
    >
    > yet I found it useful when it is also part of the definition


    You are probably the first C++ programmer ever to find exception
    specifications useful.

    > template<typename T>
    > T A<T>::someFunc()throw(SomeException){}
    >
    > what is the usual style?


    There is no usual style. No else uses them.

    Greg
     
    Greg, Oct 4, 2005
    #3
  4. On 3 Oct 2005 21:28:49 -0700, "Greg" <> wrote:

    >> yet I found it useful when it is also part of the definition

    >
    >You are probably the first C++ programmer ever to find exception
    >specifications useful.


    :-D

    I dunno. I kinda like the way that exceptions are enforced as part of the
    function type, as in Java.

    Actually, never mind.

    -dr
     
    Dave Rahardja, Oct 4, 2005
    #4
  5. In message <>, Dave Rahardja
    <> writes
    >On 3 Oct 2005 21:28:49 -0700, "Greg" <> wrote:
    >
    >>> yet I found it useful when it is also part of the definition

    >>
    >>You are probably the first C++ programmer ever to find exception
    >>specifications useful.

    >
    > :-D
    >
    >I dunno. I kinda like the way that exceptions are enforced as part of the
    >function type, as in Java.
    >

    "Enforced". I like that. The Mafia overtones have just the right ring.

    >Actually, never mind.


    --
    Richard Herring
     
    Richard Herring, Oct 6, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Philipp Holzschneider
    Replies:
    6
    Views:
    492
    Ron Natalie
    Oct 2, 2003
  2. Scott Brady Drummonds

    Exception Specifications Using Undefined Class

    Scott Brady Drummonds, Jul 29, 2004, in forum: C++
    Replies:
    1
    Views:
    369
    Denis Remezov
    Jul 29, 2004
  3. Stuart Golodetz

    Exception Specifications

    Stuart Golodetz, Sep 23, 2006, in forum: C++
    Replies:
    41
    Views:
    1,156
    Pete Becker
    Sep 27, 2006
  4. Ioannis Vranos
    Replies:
    22
    Views:
    788
    Ioannis Vranos
    Jan 22, 2008
  5. Keith Halligan

    Exception Specifications

    Keith Halligan, May 2, 2008, in forum: C++
    Replies:
    7
    Views:
    552
    James Kanze
    May 6, 2008
Loading...

Share This Page