Questions tagged [function-signature]
80 questions
3
votes
1 answer
Function signature of Tap (K-combinator)
I've read in a book that the function signature of tap function (also called K-Combinator) is below:
tap :: (a -> *) -> a -> a
"This function takes an input object a and a function that performs some action on a. It runs the given function with…

Jyoti Prasad Pal
- 1,569
- 3
- 26
- 41
3
votes
3 answers
How do I pass arbitrary member function of ANY class to template in order to resolve its signature?
In my engine, I have simple reflection system filled with classes info at compile time (that is, built around set of templates, that allows me to automate the process of generating metainfo).
Consider following example:
class Type
{
//...
…

Mateusz Grzejek
- 11,698
- 3
- 32
- 49
3
votes
1 answer
Difference between a function pointer as template argument and a function signature as template argument
What is the difference between below syntax:
template
struct A { ... };
A o1; // <--- ok
A o2; // <----- ??
I want to know the practical use of the 2nd syntax apart from libraries (I checked that we cannot declare…

iammilind
- 68,093
- 33
- 169
- 336
2
votes
1 answer
TS: Type inference across multiple interfaces and function signature not inferring?
type TypeOfSomething = "something" | "other thing";
interface HigherLevel {
subsection: MidLevel;
}
interface MidLevel {
callback: (arg: T) => void;
}
const t = { subsection: { callback:…

Smartguy 88
- 25
- 3
2
votes
2 answers
Typescript function output cannot be assigned to conditional type
I have a simplified version of a more complex problem. The following causes TSC to throw errors:
type Demo = isTrue extends true ? { a: string } : isTrue extends false ? { b: string } : never;
const func = (arg: T):…

aditya
- 1,978
- 3
- 17
- 22
2
votes
1 answer
Check that signature of two functions or member function pointer equal
I write some code for check that signature of free function is equal to signature of member function, etc. It compare extracted return type and function arguments:
#include
#include
template
struct…

Anton Lashkov
- 280
- 3
- 10
2
votes
2 answers
Derived class doesn't override a virtual function with a different signature
I have a derived class where I want one of the functions to override its version in the base class, but have a different signature.
Simple example:
#include "stdio.h"
bool use_foo = false;
class Foo {
public:
virtual int func(double x) {…

Leeor
- 19,260
- 5
- 56
- 87
2
votes
0 answers
Typescript: Generic type of function parameter signature
I try to declare a type which defines a transformation of a function type generating a type with the same arguments but another return type.
The goal is to write a function createAction which expects a function and returns a new function expecting…

remolueoend
- 71
- 1
- 5
2
votes
2 answers
creating a decorator that combines two functions without specifying the calling signature of the original function
I want to create a decorator that combines two functions and combines the parameters from their signatures.
The interface I want:
def f(a, b, c, d, e, f, g, h, i, j, k, l, m, n):
# I am using many parameters to explain the need of not
#…

johnbaltis
- 1,413
- 4
- 14
- 26
2
votes
2 answers
MonoDevelop F# tooltips for type and function signatures; Do they Exist?
Trying to work with MonoDevelop (F#) on Linux and it's quite painful without the tooltips(type/func signatures) im used to in VS. Is this functionality available in MonoDevelop? Assuming latest builds.

rbonallo
- 970
- 1
- 9
- 21
2
votes
1 answer
C++ function pointer as Template parameter
I have questions with below code snippet, not sure if I correctly understand the codes.
template
class RunnableAdapter {
public:
typedef R (RunType)(Args...);
…

Eunice
- 137
- 1
- 6
2
votes
2 answers
Fill a vector with pointers to partially specialized function members automatically
I am working on a pipeline-like design pattern. One of my design goals is to enable dynamic linking of pipeline segments by providing pointers to function members of a certain data class.
Each of the data classes has a set of function members…
user1391279
2
votes
2 answers
C++ Inhertiance: function signatures for base type not working with derived type
I have the following code:
class STFDataPoint {
public:
virtual ImagePoint get_patch_top_left() const = 0;
virtual ImagePoint get_patch_bottom_right() const = 0;
virtual std::string get_image_filename() const = 0;
virtual…

Aly
- 15,865
- 47
- 119
- 191
1
vote
3 answers
What is the use case for default argument without name in the function signature
Taken from cpp reference, https://en.cppreference.com/w/cpp/language/default_arguments
void f(int, int = 7); // #2 OK: adds a default
Is there any particular use case where this is useful, considering there is no name to the default argument.
Or I…

Daemon
- 1,575
- 1
- 17
- 37
1
vote
2 answers
Currying breaks argument type inference, because argument list gets split in two
I have this nice function which turns an object into a select option for me:
type OptionValue = string;
type OptionLabel = string;
export type Option = {
value: V;
label:…

Michal Kurz
- 1,592
- 13
- 41