wij writes:
if constexpr(!std::is_same_v<R,void>)
_exit( pfunc() );
} else {
pfunc();
_exit(0);
}
Thanks. I need C++11 way.
The C++11 way would involve using specialization, and some major
refactoring, to avoid code duplication.
explicit Process::Process<void>(void (*pfunc)()) {
followed by a specialization declaration:
template<> explicit Process::Process<void>(void (*pfunc)()) {
And, as I mentioned, the common code would need to be factored out, in some way, to avoid duplication.
Updating the compiler to something less than a decade old will probably be
much easier.
I thought about using a delegating constructor, something like:
template<> explicit Process::Process<void>(void (*pfunc)())
: Process([&]{ pfunc(); return 0; })
{
}
but this wouldn't work for the obvious reason. One could try to get this to work with a std::function, although I think this would be somewhat tricky
for overload resolution to work correctly.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)