|
Boost : |
Subject: Re: [boost] [gsoc] Boost.Process done
From: Ilya Sokolov (ilyasokol_at_[hidden])
Date: 2010-09-10 19:12:47
On Fri, 10 Sep 2010 07:26:06 -0400
"Stewart, Robert" <Robert.Stewart_at_[hidden]> wrote:
> Jeremy Maitin-Shepard wrote:
> > [snip]
> > context::map_file_descriptor(int child_fileno, file_descriptor_t
> > existing_descriptor);
> >
> > Potentially this same interface could be used on Windows, with
> > child_fileno only valid in the range 0 to 2 (and with
> > appropriate constants defined), and could thus serve as the
> > lowest level interface on top of which other behaviors like
> > pipe, redirect, etc. could be implemented.
>
> The problem with the suggested approach is that Windows winds up
> with runtime errors if the child_fileno argument exceeds the
> range. It would be better to make that a compile time error.
> The only way to do that is to use a template with the fileno
> being a template argument.
enum std_fileno { stdin, stdout, stderr }
#ifdef _WIN32
typedef std_fileno fileno;
#else
typedef int fileno;
#endif
void foo(fileno);
foo(stdout) // ok
foo(1) // ok on posix, compile error on windows
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk