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


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

Re: How to make the Process ctor work for different R type?

From wij <wyniijj5@gmail.com>
Newsgroups comp.lang.c++
Subject Re: How to make the Process ctor work for different R type?
Date 2024-11-20 00:30 +0800
Organization A noiseless patient Spider
Message-ID <c61944ca5039ccb36cb32f792c69e79a144107c7.camel@gmail.com> (permalink)
References <c7d5064e0ec2f7720f1b6cef381666cfbf249cdb.camel@gmail.com> <vhi9s8$1t262$1@raubtier-asyl.eternal-september.org>

Show all headers | View raw


On Tue, 2024-11-19 at 16:13 +0100, Bonita Montero wrote:
> Am 19.11.2024 um 03:38 schrieb wij:
> > struct Process {
> >      template<typename R>
> >      explicit Process(R (*pfunc)(), bool ret_int=false) {
> >        int pid= fork();
> >        if(pid==-1) {
> >          throw "Error";
> >        }
> >        if(pid==0) {
> >          if(ret_int) {
> >            _exit( pfunc() ); // error: invalid use of void expression
> >          } else {
> >            pfunc();         // ret value ignored
> >            _exit(0);
> >          }
> >        }
> >      };
> > }
> 
> Why do you need a generic return of the callback where you don't
> use it ? Use a function<void ()> const & parameter for pfunc so
> that you can attach an arbitrary C-function or lambda.

Not sure what you are talking about (callback???).
The current function for ForkProcess to fork has to retun int (or convertible)
or Error (overloaded). Because, other types may not be sensible.

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


Thread

How to make the Process ctor work for different R type? wij <wyniijj5@gmail.com> - 2024-11-19 10:38 +0800
  Re: How to make the Process ctor work for different R type? red floyd <no.spam.here@its.invalid> - 2024-11-18 20:34 -0800
    Re: How to make the Process ctor work for different R type? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-19 01:04 -0500
      Re: How to make the Process ctor work for different R type? Muttley@DastartdlyHQ.org - 2024-11-19 08:27 +0000
        Re: How to make the Process ctor work for different R type? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-19 10:45 +0200
          Re: How to make the Process ctor work for different R type? Muttley@DastartdlyHQ.org - 2024-11-19 09:15 +0000
      Re: How to make the Process ctor work for different R type? red floyd <no.spam.here@its.invalid> - 2024-11-20 07:23 -0800
        Re: How to make the Process ctor work for different R type? scott@slp53.sl.home (Scott Lurndal) - 2024-11-20 15:47 +0000
  Re: How to make the Process ctor work for different R         type? Sam <sam@email-scan.com> - 2024-11-19 07:07 -0500
    Re: How to make the Process ctor work for different R type? wij <wyniijj5@gmail.com> - 2024-11-19 21:16 +0800
      Re: How to make the Process ctor work for different R type? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-19 16:15 +0200
      Re: How to make the Process ctor work for different R         type? Sam <sam@email-scan.com> - 2024-11-20 07:51 -0500
  Re: How to make the Process ctor work for different R type? Bonita Montero <Bonita.Montero@gmail.com> - 2024-11-19 16:13 +0100
    Re: How to make the Process ctor work for different R type? wij <wyniijj5@gmail.com> - 2024-11-20 00:30 +0800
      Re: How to make the Process ctor work for different R type? Bonita Montero <Bonita.Montero@gmail.com> - 2024-11-19 17:42 +0100
        Re: How to make the Process ctor work for different R type? Bonita Montero <Bonita.Montero@gmail.com> - 2024-11-21 15:27 +0100
          Re: How to make the Process ctor work for different R type? Muttley@DastartdlyHQ.org - 2024-11-21 16:11 +0000
            Re: How to make the Process ctor work for different R type? Bonita Montero <Bonita.Montero@gmail.com> - 2024-11-21 17:59 +0100
              Re: How to make the Process ctor work for different R type? Muttley@DastartdlyHQ.org - 2024-11-22 09:54 +0000
          Re: How to make the Process ctor work for different R type? wij <wyniijj5@gmail.com> - 2024-11-22 00:32 +0800

csiph-web