octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax for using function pointers in C++


From: John Swensen
Subject: Re: syntax for using function pointers in C++
Date: Wed, 21 Oct 2015 09:19:56 -0700


On Oct 21, 2015, at 9:11 AM, John W. Eaton <address@hidden> wrote:

When calling a function using a function pointer we sometimes use the C syntax

 (*fptr) (...);

and sometimes the syntax allowed by C++

 fptr (...);

is there any consensus on what is the best style?  I'd like for us to consistently use one or the other.

Or is there something else we should be doing with modern C++ instead of function pointers (though I'm afraid we may be stuck on this one in many cases because of backward compatibility reasons)?

Other Comments?

Preferred bikeshed colors?

jwe


I have seen a few projects start to use std::function (available since C++11). I haven’t used it myself, but when I first saw it used I went searching for pros & cons versus function pointers. I found the following StackOverflow article at the time which described them well.

http://stackoverflow.com/questions/25848690/should-i-use-stdfunction-or-a-function-pointer-in-c

John S.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]