Questions tagged [function-object]

In object-oriented languages, function object (also known as functor) is a feature that allows objects to be used like if they were ordinary functions.

168 questions
-2
votes
2 answers

How to invoke any swift function conditionally (without if block)

I want to write a general-purpose Swift function that serves the following simple purpose: Take any function as argument Take a Bool argument If the bool argument is TRUE, invoke the input function with its args. Otherwise No-op. The purpose is to…
Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89
-2
votes
1 answer

a call to template-function - is it legal?

I have a template function (generic func to find the minimum), which look's like that: template int findmin(const T* a, int n, Func less){ //... } and a call: int smallest_matrix(const Matrix*a, int n){ return…
-8
votes
1 answer

Why are function objects better than function pointers?

from Wikipedia - Function object A typical use of a function object is in writing callback functions. A callback in procedural languages, such as C, may be performed by using function pointers.[2] However it can be difficult or awkward to pass a…
JPH
  • 9
  • 7
1 2 3
11
12