overloading Questions

3

Basically I'm just trying to wrap a function that has multiple signatures. Is there any clean way to do this without re-hardcoding all of the signatures? I just want bar below to accept any of the ...
Stretchy asked 16/11, 2021 at 15:22

8

Solved

Is it possible in typescript to define a function type and extend its argument list in another type (overloading function type?)? Let's say I have this type: type BaseFunc = (a: string) => Promi...
Shool asked 12/9, 2018 at 11:12

2

Solved

I'm trying to pass a specific overload of std::isfinite() to a function, but GCC refuses: 0.cpp:9:24: error: no matching function for call to ‘all_of(std::array<double, 2>::const_iterator, st...
Dacy asked 13/6, 2024 at 9:50

3

Solved

I have a template class Array: template <class T=int, int SIZE=10> class Array { T TheArray[SIZE]; public: void Initialize() { for (int idx=0; idx < SIZE; idx++) { TheArray[idx] = T()...
Protrusile asked 4/1, 2016 at 14:22

7

Solved

I am trying to create a function passes its arguments to another function. Both of these functions need to have the same overloads. function original (a: number): boolean; function original (a: str...
Burschenschaft asked 2/12, 2020 at 15:10

3

Solved

How is this expected to work? struct S {}; void foo(volatile S&); void foo(S); int main() { volatile S v; foo(v); } Compilers disagree on it: MSVC accepts the code, while Clang and GCC say...

13

Solved

How can I declare a few methods with the same name, but with different numbers of parameters or different types in one class? What must I change in the following class? class MyClass: ""...
Wallin asked 22/2, 2011 at 14:48

3

Solved

I've recently started to learn app development in Android Studio and Kotlin so I am a total beginner but I learn fast. However, I stumbled on this error: "Overload resolution ambiguity. All th...
English asked 14/2, 2024 at 15:46

10

Related: Function returning constexpr does not compile I feel like constexpr is limited in usefulness in C++11 because of the inability to define two functions that would otherwise have the same s...
Caruso asked 20/1, 2012 at 3:54

3

Here is a piece of code that tries to provide a pointer to an overloaded function to another function that can accept a value of any type: template <typename T> void AcceptAnything(T&&amp...
Langford asked 16/3, 2024 at 7:53

10

Solved

I would like to call a method which could potentially take on different versions, i.e. the same method for input parameters that are of type: boolean byte short int long The way I would like to...
Reposit asked 7/9, 2010 at 20:9

6

Solved

Section 6.3 of the TypeScript language spec talks about function overloading and gives concrete examples on how to implement this. However if I try something like this: export class LayerFactory { ...
Metamorphosis asked 3/11, 2012 at 19:22

4

Solved

A textbook I have notes that you can provide your own implementation for standard library functions like swap(x,y) via template specialization or function overloading. This would be useful for any ...
Sustenance asked 18/8, 2011 at 13:17

2

Solved

I am looking for an example where a dot in a function name causes R's Method Dispatch to pick the wrong function. A natural candidate seems to be the builtin function t.test(), which should be conf...
Prohibitionist asked 14/11, 2023 at 14:24

3

Solved

Today I ran into roughly the following code: #include <iostream> void f(float&& f) { std::cout << f << "f "; } void f(int&& i) { std::cout <&lt...

18

I am trying to implement method overloading in Python: class A: def stackoverflow(self): print ('first method') def stackoverflow(self, i): print ('second method', i) ob=A() ob.stackoverflow(...
Hymeneal asked 18/4, 2012 at 4:47

7

Solved

Is it possible to create a constructor (or function signature, for that matter) that only accepts a string literal, but not an e.g. char const *? Is it possible to have two overloads that can dist...
Rumelia asked 11/1, 2010 at 11:3

5

Solved

I'm porting a C library to Go. A C function (with varargs) is defined like this: curl_easy_setopt(CURL *curl, CURLoption option, ...); So I created wrapper C functions: curl_wrapper_easy_setop...
Billiot asked 8/8, 2011 at 18:42

20

I'd like to know: Why can't static methods be overridden in Java? Can static methods be overloaded in Java?
Dyl asked 19/3, 2010 at 5:58

3

Solved

Static and non-static member functions with the same parameter types cannot be overloaded. But if member functions are templates and one of them has requires clause then all compilers allow it. But...
Hyssop asked 31/12, 2021 at 12:19

10

Solved

I am writing a method that should accept as its parameter an object of one of two types which do not share a parent type other than Object. For example, the types are Dreams and Garlic. You can do ...
Digital asked 27/5, 2012 at 21:22

10

Solved

Is there any way to override a non-virtual method? or something that gives similar results (other than creating a new method to call the desired method)? I would like to override a method from Mic...
Sarilda asked 5/12, 2009 at 23:45

20

I know that Python does not support method overloading, but I've run into a problem that I can't seem to solve in a nice Pythonic way. I am making a game where a character needs to shoot a variety ...
Roaster asked 22/6, 2011 at 3:11

1

The code below allows you to see size of variable being deleted: #include <iostream> #include <stdlib.h> using namespace std; struct P { static void operator delete(void* ptr, std::si...
Charlenacharlene asked 13/7, 2023 at 0:48

16

Solved

Is there any way to achieve function overloading in C? I am looking at simple functions to be overloaded like foo (int a) foo (char b) foo (float c , int d) I think there is no straight forwa...
Cheung asked 26/1, 2009 at 9:20

© 2022 - 2025 — McMap. All rights reserved.