Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
451 views

I am mocking a class with two overloaded methods like this: //required because some versions of gtest messes with extra commas in MOCK_METHOD typedef std::pair<char*, uint32_t> KeyValueType; ...
roschach's user avatar
  • 9,636
2 votes
3 answers
137 views

I have this pattern in my code: public: int start(const uint32_t channel); int stop(const uint32_t channel); void set_current_desc(uint32_t channel, uint64_t cdesc); // ... private: ...
magnusmaehlum's user avatar
2 votes
0 answers
101 views

I have some C++ code that uses templates to create function wrappers around member functions. Here is a link to code on the compiler explorer, and here is the same code below. It's a simplification of ...
Rob N's user avatar
  • 16.7k
1 vote
2 answers
167 views

I have this c++ template function template <int N, int B, auto... Args> void somefunc() { // do work... } , which I can call like this: somefunc<1, true, 2, false>(); I want to ...
lobelk's user avatar
  • 531
5 votes
1 answer
122 views

I have a hierarchy of classes for which I want to define a generic-type binary operation. I want to define and employ a concept in order to constrain the overloads. While the code works, the use of ...
Involute's user avatar
  • 245
1 vote
1 answer
76 views

Consider the simple GLSL ES 1.0 and 3.0 code int i = f(); When f() is not defined, this produces 2 errors: ERROR: 0:41: 'f' : no matching overloaded function found ERROR: 0:41: '=' : cannot convert ...
dubious's user avatar
  • 259
-3 votes
1 answer
114 views

I wrote a code for a project about a famous mathematical constant called the constant of Krapekar. Every number that has four digits, being at least two of them different from each other, will be ...
Arquiloco's user avatar
1 vote
2 answers
148 views

When designing a (performant) method with variable parameter length like <T> void consume(T t1) <T> void consume(T t1, T t2) <T> void consume(T t1, T t2, T t3) and a) another ...
bjmi's user avatar
  • 615
2 votes
1 answer
67 views

I have a class MyClass with two simple templated member functions that have the same name test, but one of them is marked as static and their signatures are different: #include <array> #include &...
Timo Wild's user avatar
1 vote
1 answer
63 views

Assume the next scenario: interface FloatObject<V> extends Function<Float, V> { V apply(Float floatObject); default FloatObject<Float, V> x_5() { return aFloatObject -&...
Delark's user avatar
  • 1,385
2 votes
4 answers
165 views

Hi there I am facing the following problem: I have a class with many member functions of a certain pattern. Each of these member functions has 3 overloads and these overloads are the same for all ...
user-1's user avatar
  • 43
0 votes
1 answer
68 views

I have 2 classes each implementing a specific behavior and using parent classes. Now I have a new class that needs to use either behavior but which one can only be determined during/after construction....
Flamefire's user avatar
  • 5,927
2 votes
1 answer
85 views

I have the following C++ code which outputs 12: #include <iostream> using namespace std; template<typename T> T foo(T val) { return val; } template<typename T> T bar(T n) { ...
Yuqi Huang's user avatar
3 votes
1 answer
138 views

I have to classes Derived1 and Derived2 derived from an abstract base class Base. I also have a class Container, that contains a map of unique pointers to objects of the Base class, because I want to ...
lordlol's user avatar
  • 33
1 vote
1 answer
56 views

I have a class called Block that has a Draw method. I want to make a function that draws a group of blocks all at once. Since some groups are Arrays and some are lists, I had to add an overload that ...
kneecapfolder's user avatar
-1 votes
1 answer
59 views

I have LCD class which is run by micropython on raspberry pi pico which i initialise like this: class Lcd: def __init__(self, width, height, channel, sdaPin, sclPin, contrast): from time ...
shifras's user avatar
2 votes
1 answer
119 views

I just encountered a new compilation error in my code after a visual studio update. I have stripped my code down to what I think is a minimal example. I have two templated functions both called pow - ...
Phil Rosenberg's user avatar
3 votes
1 answer
147 views

I'm trying to overload operator += .. of course this's not possible by code but If I have not been fooled by docs once overloaded the + operator the += operator will be implicity overloaded. public ...
weirdgyn's user avatar
  • 1,018
1 vote
1 answer
59 views

In TypeScript, I can easily create a function with overloads that returns a different return type depending on the input. E.g.,: function doSomething(mode: "ReturnPromise"): Promise<any&...
Michael Zlatkovsky's user avatar
2 votes
1 answer
323 views

Returning an overloaded function from a higher-order callable does not produce expected results with respect to type hints: namely, the resulting function behaves as if it was unannotated at all. Here ...
algebruh's user avatar
  • 410
0 votes
1 answer
86 views

If I understand this correctly, [over.load] doesn't exist in c++23, and so what I read in [over.load]/2.3 should not be true anymore, so this code struct Foo { int const& bar() const; int bar()...
Enlico's user avatar
  • 30.3k
2 votes
6 answers
205 views

In C++20, instead of doing size_t count = 42; std::vector<int> my_vector; vec.reserve(count); std::copy_n(std::istream_iterator<T>(std::cin), count, std::back_inserter(vec)); I want to be ...
ashpool's user avatar
  • 255
1 vote
2 answers
47 views

How we can get a method such as Tuple.Create that has multiple generic overloads through reflection and use it with our custom generic type arguments? usecase: the generic type arguments are known ...
Mansoor Omrani's user avatar
0 votes
0 answers
85 views

Let's say I have this function from typing import reveal_type def func(x: str | list[str]) -> int | list[int]: """ Some docstring that should show up. """ ...
chicxulub's user avatar
  • 482
0 votes
1 answer
49 views

I have two functions which have the same overloading of parameters but return different things. Is there someway I can abstract the overloading definition into a shared definition that I can reference ...
wheresrhys's user avatar
  • 23.7k
2 votes
3 answers
127 views

I need to have an interface to the driver that provides a set of send() functions only of the following types: void send(u8 a); void send(u8 a, u8 b); void send(u8 a, u8 b, u8 c); void send(u8 *a, u32 ...
Evgeny Ilyin's user avatar
0 votes
1 answer
50 views

I have a legacy project that has a base class which represents complex objects that are built at runtime. These objects have a state with getter/setter methods for the state properties. In some cases, ...
JDB's user avatar
  • 26.1k
11 votes
2 answers
963 views

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, std::...
Toby Speight's user avatar
  • 32.3k
2 votes
0 answers
171 views

I'm trying to build the Nvidia's Minkowski Engine, so I did the following: git clone https://github.com/NVIDIA/MinkowskiEngine.git cd MinkowskiEngine python setup.py install However, I get this ...
Megapiot's user avatar
1 vote
1 answer
66 views

Some background I am very new to Swift and MacOS and trying to learn the Swift way to do things. This started because I realized that tuples are not hashable so I rolled my own: struct XY: Hashable { ...
nilgirian's user avatar
  • 135
2 votes
2 answers
70 views

function overloading I wrote the 2 interfaces. Also I wrote 3 overloading functions. And I have implementation of functions. And here an error - This overload signature is not compatible with its ...
Дарья Орлова's user avatar
0 votes
0 answers
38 views

Here are two code snippets for example class HelloWorld { public void method(Object a){ System.out.println("object"); } public void method(int... a){ System....
Karan's user avatar
  • 1
1 vote
1 answer
71 views

Coming from this helpful question/answer: Constructor chaining in PowerShell - call other constructors in the same class. To be consistent with the way you call a constructor (e.g. [car]::new()) and ...
iRon's user avatar
  • 24.4k
6 votes
3 answers
317 views

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 ...
Dr. Gut's user avatar
  • 3,335
0 votes
1 answer
100 views

A string literal when passed to a function will be deduced to be first a const char (&)[] array first, and then if not function is suitable it will decay to a const char*. So I thought that the ...
Zebrafish's user avatar
  • 16.3k
0 votes
1 answer
50 views

I'm trying to overload the login function so that when i pass in an argument to it the return type gets inferred as LoginResponse and when i don't pass any arguments it gets inferred as void | Error. ...
Hack3r's user avatar
  • 79
0 votes
0 answers
39 views

Im working on a school project focusing on a few topics from overloading to templates It's a multifile project with 2 custom classes that contain a vector of the other ones type Inside of the Race ...
IronCladMoon's user avatar
0 votes
0 answers
86 views

The thing I am doing is making a Growable Array class in c++ and am using templates for it and in this implementation I have also a subclass iterator //forward olny and then in the main this line is ...
M Hamza Naveed's user avatar
0 votes
1 answer
57 views

Suppose I have 3 classes: example.h class Object { public: Object(); void pass_self_to_external_class(); }; class ObjectWithExtraMember : public Object { public: ObjectWithExtraMember(); ...
Henry Nissen's user avatar
0 votes
2 answers
134 views

Consider having a simple class, that writes integers to cout depending on its state: #include <iostream> class NotAWriter{ public: NotAWriter& operator<<(const int& arg) { ...
MPEI_stud's user avatar
  • 135
0 votes
0 answers
89 views

I'm trying to unit-test some overloaded Python methods, in an attempt to increase the overall coverage of my code. Here are the overloaded methods, and the main method that is associated with them: @...
Austin's user avatar
  • 61
0 votes
0 answers
90 views

I am trying to override Pydantic's and SQLModel's Field function. I have 3 boolean arguments which indicate different combinations: If is_table_field == True, then return SQLModel's FieldInfo, else ...
KOB's user avatar
  • 4,645
0 votes
1 answer
83 views

I'm trying to make TypeScript correctly infer the return type of a function (the result) based on the context in which it was called. TS correctly infers the result as 'isA' | 'isB' because the input ...
Mikel's user avatar
  • 6,252
0 votes
1 answer
47 views

I can't figure out how to call the display method from shape class to the Main method. This is for an assignment, and we're not supposed to change what's written in Main, so the problem has to come ...
sufferingThruSchool's user avatar
1 vote
1 answer
100 views

I have a class Vec<C> that works as below, and I need to know a way to write the constructor and/or deduction guide such that a braced-enclosed initializer list deduces C as std::array<T,N>...
Astor's user avatar
  • 394
1 vote
1 answer
127 views

I have written a DLL with a bunch of different procedures and functions using Delphi. There is one function within this DLL that I want to overload, but as soon as I do, I get a host of errors on all ...
Skypilot65's user avatar
0 votes
1 answer
69 views

I have custom functions utf8Char (decimal) and utf8Byte(char). How can I overload the functions string.char(...) and string.byte(s, i, j) in Lua? Here is an example function what I mean: local ...
darkfrei's user avatar
  • 638
1 vote
1 answer
50 views

I want to implement a function that can infer the return type through different parameters. The type can be inferred normally when calling directly, but when using a function to return parameters, the ...
Purple awn's user avatar
1 vote
1 answer
82 views

I'm new to generics in typescript, it's confusing is there a way to make the spread operator ... work in the snippet below the issue the line [ key: U, ...rest: Reg[U] ], doesn't work as I expect the ...
azzmi's user avatar
  • 75
0 votes
1 answer
126 views

First off, I would like to draw special emphasis to the C++20 tag, as I believe this problem is much easier to solve using concepts and the requires statement. Second, when I say array here, I mean ...
Smasheded's user avatar
  • 116