Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #89569

Re: Why no structured bings in catch()?

Newsgroups comp.lang.c++
Date 2023-03-09 03:18 -0800
References <tu9mji$s58j$1@dont-email.me> <tuagh8$10o2k$1@dont-email.me> <tuc802$1clhv$1@dont-email.me>
Message-ID <06d63d44-e1ca-4ac9-b4e4-32aaec730b86n@googlegroups.com> (permalink)
Subject Re: Why no structured bings in catch()?
From Öö Tiib <ootiib@hot.ee>

Show all headers | View raw


On Thursday, 9 March 2023 at 11:13:55 UTC+2, Mut...@dastardlyhq.com wrote:
> On Wed, 8 Mar 2023 18:28:32 +0100 
> Bonita Montero <Bonita....@gmail.com> wrote: 
> >Am 08.03.2023 um 11:04 schrieb Mut...@dastardlyhq.com: 
> > 
> >> Just discovered that I can't do this in C++17: 
> >> throw pair<string,int>("hello",123) 
> >> catch(auto &[str,val]) 
> >> { 
> >> } 
> >> Is there a good reason why this can't be implemented? 
> > 
> >With the thrown object there's some type information passed 
> >along to verify if it fits against the type being catched. 
> >If you want to catch sth. auto-ish you won't have a strong 
> >type-match. So this doesn't work.
> 
> Does it need to be a strong match? If the runtime knows a pair has been 
> thrown - and it must or it couldn't be caught at all - then why can't it 
> do a match to see if an auto matches? Yes it'll be more complex than the 
> current system but I don't see why it would be impossible.

Sam writes a function bar() that has switch case in it that throws
different objects from long list of struct {? a; ? b;} , std::array<?,2>, std::tuple<?,?>,
std::pair<?, ?>, etc. Each case different types in places of those
question marks. What do your str and val bind to in your foo() that calls
that bar()?
 

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-08 10:04 +0000
  Re: Why no structured bings in catch()? Öö Tiib <ootiib@hot.ee> - 2023-03-08 03:23 -0800
    Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-08 11:45 +0000
      Re: Why no structured bings in catch()? Sam <sam@email-scan.com> - 2023-03-08 07:13 -0500
        Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-08 16:21 +0000
          Re: Why no structured bings in catch()? Bo Persson <bo@bo-persson.se> - 2023-03-08 19:21 +0100
          Re: Why no structured bings in catch()? Sam <sam@email-scan.com> - 2023-03-08 19:39 -0500
            Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-09 09:12 +0000
              Re: Why no structured bings in catch()? Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-09 10:16 +0100
              Re: Why no structured bings in catch()? Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-09 14:06 +0200
              Re: Why no structured bings in catch()? Sam <sam@email-scan.com> - 2023-03-10 06:58 -0500
      Re: Why no structured bings in catch()? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2023-03-08 14:55 -0800
  Re: Why no structured bings in catch()? Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-08 18:28 +0100
    Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-09 09:13 +0000
      Re: Why no structured bings in catch()? Öö Tiib <ootiib@hot.ee> - 2023-03-09 03:18 -0800
      Re: Why no structured bings in catch()? Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-09 17:06 +0100
      Re: Why no structured bings in catch()? Christian Gollwitzer <auriocus@gmx.de> - 2023-03-10 08:12 +0100
        Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-10 10:05 +0000
          Re: Why no structured bings in catch()? Öö Tiib <ootiib@hot.ee> - 2023-03-10 05:04 -0800
            Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-10 16:14 +0000
  Re: Why no structured bings in catch()? Daniel <danielaparker@gmail.com> - 2023-03-09 11:38 -0800
    Re: Why no structured bings in catch()? Muttley@dastardlyhq.com - 2023-03-10 10:03 +0000

csiph-web