🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by PWLee Thu, 26 Oct 1995 14:58
C++ Standard
#2311
Author: PWLee
Date: Thu, 26 Oct 1995 14:58
75 lines
3747 bytes
I wonder if anyone has a copy of C++ standard could e-mail me a copy of it.  I have tried couple web site such as research.att.com/dist/c++std/wp and ftp/maths.warwick.ac.uk/c++/std/wp but none of those are accessable.  Please e-mail me a copy or let me know if other web site obtain one.  Thanks in advance.


Peter Lee
PLEE@HEART.COM


From daemon@ncar.UCAR.EDU Wed Oct 25 22:59 PDT 1995
Return-Path: <daemon@ncar.UCAR.EDU>
Received: from Eng.Sun.COM (engmail1) by pacific.eng.sun.com (5.x/SMI-SVR4)
	id AA21099; Wed, 25 Oct 1995 22:59:05 -0700
Received: from mercury.Sun.COM (mercury.EBay.Sun.COM) by Eng.Sun.COM (5.x/SMI-5.3)
	id AA26955; Wed, 25 Oct 1995 22:58:47 -0700
Received: from ncar.UCAR.EDU by mercury.Sun.COM (Sun.COM)
	id WAA27828; Wed, 25 Oct 1995 22:58:46 -0700
Received: by ncar.ucar.EDU (NCAR Local/ NCAR Central Post Office 03/11/93)
	id XAA03421; Wed, 25 Oct 1995 23:58:43 -0600 (MDT)
Received: from relay-2.mail.demon.net by ncar.ucar.EDU (NCAR Local/ NCAR Central Post Office 03/11/93)
	id XAA03418; Wed, 25 Oct 1995 23:58:37 -0600 (MDT)
Received: from post.demon.co.uk by relay-2.mail.demon.net id af22419;
          26 Oct 95 5:19 GMT
Received: from relay-2.mail.demon.net by relay-3.mail.demon.net id aa13892;
          26 Oct 95 4:55 GMT
Date: Thu, 26 Oct 95 03:37:28 GMT
Message-Id: <6037@thone.demon.co.uk>
From: Andy Sawyer <andys@thone.demon.co.uk>
Organization: The United Federation Of Planets
Reply-To: andys@thone.demon.co.uk
To: std-c++@ncar.ucar.edu
Subject: diagnostic exceptions
X-Mailer: Demon Internet Simple News v1.29
Lines: 33
Content-Type: text
Content-Length: 1313
X-Lines: 33
Status: RO

In article <ACB2F42C9668BCA1@sleipner.nts.mh.se>
           lars.farm@nts.mh.se "Lars Farm" writes:

 > 
 > The diagnostic exception classes are constructed from a const string&.
 > Will they copy the text or store a reference to the string?
 > 
[snip]

 I have a slightly different thought on this .. why do the constructors
require a string& instead of a const char * ? (The whole thing is further
obfuscated by the base exception class not having a constructor which takes
the const string& parameter).

IMHO, it would be highly desireable if the base class had such a
constructor (perhaps protected) which takes such a parameter. I am keen to
see this in the standard, since it is the obvious implementation...which
I expect most vendors to follow, but if it is not standardized, then there
will always be someone who doesn't.

(I am thinking here primarily of user-defined exception classes, which
derive from exception, but not from logic_error or runtime_error)

Thoughts, anyone?

Regards,
 Andy

-- 
* Andy Sawyer ** e-mail:andys@thone.demon.co.uk ** Compu$erve:100432,1713 **
 The opinions expressed above are my own, but you are granted the right to
 use and freely distribute them. I accept no responsibility for any injury,
 harm or damage arising from their use.                --   The Management.

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: C++ Standard
#2326
Author: Lars Farm
Date: Fri, 27 Oct 1995 14:55
85 lines
4197 bytes
In article <46mads$qvv@turtle.hearst.com>,
PWLee@@ns1.hearst.com wrote:

>In article <ACB2F42C9668BCA1@sleipner.nts.mh.se>
>           lars.farm@nts.mh.se "Lars Farm" writes:
> > The diagnostic exception classes are constructed from a const string&.
> > Will they copy the text or store a reference to the string?

> I have a slightly different thought on this .. why do the constructors
>require a string& instead of a const char * ?

I'd like to see a const char* ctor in addition to the string& ctor. Perhaps
this is already allowed?

> (The whole thing is further
>obfuscated by the base exception class not having a constructor which takes
>the const string& parameter).
>
>IMHO, it would be highly desireable if the base class had such a
>constructor (perhaps protected) which takes such a parameter. I am keen to
>see this in the standard, since it is the obvious implementation...which
>I expect most vendors to follow, but if it is not standardized, then there
>will always be someone who doesn't.

class exception can not be allowed to carry a string object because class
bad_alloc is derived from it, as are the other language support exception
classes. If you're out of RAM and wants to throw bad_alloc, then you might
not be able to construct the string in the base class and thus not be able
to throw bad_alloc. Bad. None of the language support exception classes
needs any data at all. I suppose exception::what() could be implemented:

  const char*exception::what() const { return typeid(*this).name(); }

which would be sufficient for all the language support exceptions.

>(I am thinking here primarily of user-defined exception classes, which
>derive from exception, but not from logic_error or runtime_error)
>
>Thoughts, anyone?

For your own exception classes you might perhaps do the same as
runtime_error/logic_error. Introduce your own base with whatever data/ctors
you need:

    class my_exception_base : public exception {
      string s;
    public:
      my_exception_base(const string& what_arg) :s(what_arg){}
      const char* what() const { return s.c_str(); }
    };
    class my_kindof_error1 : public my_exception_base { ... };
    class my_kindof_error2 : public my_exception_base { ... };
    ...

This brings me back to my original question, so far unanswered. I asked
because I disagree with my compiler vendor about interpretation of the
draft. I believe that the diagnostic exceptions (file <stdexcept>) should
carry a copy of the text. They do not, and implements it with a reference
to string, like so:

    class logic_error : public exception {
      const string& s;
    public:
      logic_error(const string& what_arg) :s(what_arg){}
      const char* what() const { return s.data(); }
    };

The draft says (string& ctor): "post:what()==what_arg.data()" which taken
literaly supports their interpretation. Can this really be the intent? (see
above referenced article) If so, you can't say 'throw
logic_error("error")'. You must init the exception object from a static
string object. This in turn means you can't throw standard exceptions from
a catch handler... So I think that "what()==what_arg.data()" must be
interpreted "two identical texts" rather than "one shared text"

Does anyone know for sure?

 - Lars

--
Lars Farm, lars.farm@nts.mh.se

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads