Path: utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!apple!usc!ucla-cs!uci-ics!news
From: schmidt@zola.ics.uci.edu (Doug Schmidt)
Newsgroups: gnu.g++.bug
Subject: Re: installing g++.xtar
Message-ID: <1989Oct3.161351.6319@paris.ics.uci.edu>
Date: 3 Oct 89 16:13:51 GMT
References: <8910031152.AA13388@g.oswego.edu>
Sender: news@paris.ics.uci.edu (Network News)
Reply-To: schmidt@zola.ics.uci.edu (Doug Schmidt)
Distribution: gnu
Organization: University of California, Irvine - Dept of ICS
Lines: 75
In-reply-to: dl@G.OSWEGO.EDU (Doug Lea)

I've now got the latest libg++ and g++ up and running successfully on
the Sun 4, Sun 3, and Sequent Symmetry.  If anyone has any baffling
problems you can send me a note.

Also, for your hacking enjoyment, here is some sample exception handling
code.  To compile this type

% g++ -fhandle-exceptions foo.cc

Then type

% a.out m; a.out l

The example is rather contrived, but it illustrates some basic
syntactic and semantics points.

Please note that this new exception handling feature is experimental
and subject to change.

Doug
----------------------------------------
#include 
#include 

class Search
{
private:
  char *buf;

public:
  exception { char item;} NOT_FOUND;

  Search (char *s) { buf = s; printf ("search buffer = %s\n", s); }

  int operator () (char c)
    {
      int i;
      for (i = 0; buf[i]; i++)
        if (buf[i] == c)
          return i;
      raise NOT_FOUND (c);
    }

  ~Search () { printf ("I should get printed regardless...\n"); }
};

main (int argc, char **argv)
{
  if (argc != 2)
    {
      printf ("usage: %s letter\n", argv[0]);
      exit (1);
    }
  else
    {
      Search search ("jammer");

      try
        {
          printf ("item found in location %d!\n", search (*argv[1]));
        }
      except search_item
        {
          Search::NOT_FOUND
            {
              printf ("item %c not found...\n", search_item.item);
            }
        }
    }
}
--
schmidt@ics.uci.edu (ARPA) |   Per me si va nella citta' dolente.
office: (714) 856-4043     |   Per me si va nell'eterno dolore.
                           |   Per me si va tra la perduta gente.
                           |   Lasciate ogni speranza o voi ch'entrate.