?
=?ISO-8859-15?Q?Juli=E1n?= Albo
Julián Albo said:Did you have? Looks like you are asking for advice because you haven't.
Sorry, I make a mistake between your name and the OP.
Julián Albo said:Did you have? Looks like you are asking for advice because you haven't.
Julián Albo said:Sorry, I make a mistake between your name and the OP.
Pete said:You're welcome to spend as much time as you like seeking purity. I'll
trust Unix compilers to continue support standard idioms such as storing
function addresses in void*'s, and I'll have robust, working code long
before you do.
Something must be giving you the confidence to regard that as a
standard idiom that will benefit from continuing support. It's not the
language standard. Is it the compiler documentation? I hope I was clear
in my point that I regard compiler documentation of non-standard
behaviour an equally valid source of such confidence as the standard
itself.
Alf said:* Gavin Deane:
Presumably Pete is referring to any reliable system documentation
whatsoever, such as (1) compiler documentation, and/or (2) the Posix
standard.
There is a difference between 100% portable standard C++ code and
in-practice C++ code.
One difference is, of course <g>, that in 100% portable C++ code you
can't do any i/o, since some systems have no i/o devices compatible with
the forms of i/o supported by the standard library... So there's really
not very much that can be done in 100% portable C++. Even "Hello,
world!" is not 100% portable: it requires a system with text display.
So the question is always (although unfortunately most often left
unstated): what is the range of systems that this code is meant to be
portable to? When that range is "Posix-compliant systems", storing
function pointers in void* is perfectly OK, as far as I know.
* Gavin Deane:
Presumably Pete is referring to any reliable system documentation
whatsoever, such as (1) compiler documentation, and/or (2) the Posix
standard.
There is a difference between 100% portable standard C++ code and
in-practice C++ code.
One difference is, of course <g>, that in 100% portable C++ code you
can't do any i/o, since some systems have no i/o devices compatible
with the forms of i/o supported by the standard library... So there's
really not very much that can be done in 100% portable C++. Even
"Hello, world!" is not 100% portable: it requires a system with text
display. So the question is always (although unfortunately most often
left unstated): what is the range of systems that this code is meant
to be portable to? When that range is "Posix-compliant systems",
storing function pointers in void* is perfectly OK, as far as I know.
Alf said:There is a difference between 100% portable standard C++ code and
in-practice C++ code.
Marcus said:Greg said:Function-to-object pointer conversions have been added to standard C++
as a "conditionally supported" conversion using reinterpret_cast<>:
"Converting a pointer to a function into a pointer to an object type or
vice versa is conditionally-supported. The meaning of such a conversion
is implementation defined, except that if an implementation supports
conversions in both directions, converting an rvalue of one type to the
other type and back, possibly with different cv-qualification, shall
yield the original pointer value." [expr.reinterpret.cast/8]
Interesting, thanks.
Conditionally-supported behavior is one that an implementation is not
required to support. But an implementation does support the feature
must then implement the feature as specified.
Is there a consolidated list of other "conditionally-supported"
features?
Greg said:Not that I know of, so I tried putting together a list myself. Aside
from the pointer-to-object opointer-to-function conversion, the other
conditionally-supported behaviors that I found, are:
A character escaped with a backslash:
A non-POD type parameter in variable argument list:
The "asm" directive:
Templates with non-C, non-C++ language linkage
Not the most exciting list of features, I would admit.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.