>From: "Bohdan" <[EMAIL PROTECTED]>

> IMHO a very useful addon to your library can be routine
> to convert class to function which calls class destructor.

<snip>

>         //no virtual functions, no runtime polymorphism
>         void * ptr = new MyClass;
>         destruct_fn_type df = destruct_fn<MyClass>();
>
>         ....
>         df(ptr);

Right. Your code works fine, and is also completely independent of
function_ptr, so might be useful as a utility in its own right. :)

Anyway, regarding function_ptr, as modern C++ typically is generic, so that
an entity only need to be "callable" (a function object or function
pointer), and that function objects also supports binding of parameters,
function_ptr probably have little use in modern C++.

When it comes to APIs that use function pointers, it also needs to be a C++
API, as function_ptr can't be used as an "extern "C"" function. Also, the OP
at the newsgroup prefers a macro to do this, after all, to avoid even
stating the function signature.

It was an interesting challenge, anyway. :)


Regards,

Terje

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to