Questions tagged [function-templates-overloading]
32 questions
1
vote
2 answers
Overloading generic function on optional parameter in Swift
I'm trying to write a library that uses templated/generic type dispatch, but I can't figure out how overload resolution works in Swift. (Is there a more technical reference than The Swift Programming Language?)
The following works exactly as I'd…

rvcx
- 51
- 4
0
votes
0 answers
How to restrict overloaded function applicability so that it only applies to certain types in order to avoid ambiguous call errors
I have a class that I use to apply functions to each element in a vector representing an image.
template
class func1_img_expr_t : public img_expr_t {
public:
std::function f;
E e;
…

Adrian K-B.
- 99
- 1
- 8
0
votes
0 answers
How to appropriately overload a VBA function requiring different object types for a parameter
Below have a function to be overloaded requiring one parameter that can be either a DateTime or DateTimeOffset object.
What would be the appropriate method to implement this overloading?
i.e
GetUtcOffset(optional Byval inDateTime as DateTime,…

M. Johnstone
- 72
- 1
- 6
0
votes
1 answer
overloaded function in C++
I am getting compiler error of overloaded function is ambiguous.
although i understand what it means but how to resolve this problem?
#include
using namespace std;
int area(int );
int area(int ,int );
…

Jasmeet Singh
- 101
- 3
0
votes
1 answer
MSVC not able to disambiguate between function templates when one of them contains a pack
Recently I reported a msvc bug involving a function parameter pack. Also as it turns out here that msvc is actually standard compliant there.
Then when I modified the example to what is shown below I noticed that the modified code also cannot be…

Jason
- 36,170
- 5
- 26
- 60
0
votes
0 answers
: ld: fatal: symbol referencing errors
I am facing the error as in below,
Undefined first referenced
symbol in file
void bcMwMrsh::cppListFromWire(void*&, RWTValSlist >&, AISObject*…

Puneeth
- 419
- 1
- 6
- 18
0
votes
3 answers
Moving the function templates definition to different translation unit resolves the ambiguity error
I was using function templates when I noticed that moving the definition of one of the function template to a different translation unit resolves the ambiguous error. Below are the two examples that I tried. The first example produces ambiguous…

Jason
- 36,170
- 5
- 26
- 60
0
votes
0 answers
Add function template specialisation for double types only in a template class
I have an implementation of a class template with a base class.
class MyBase
{
protected:
virtual void getErrorPercent(std::ostream& fileStream) = 0;
virtual void getFormattedText(std::ostream& fileStream) = 0;
};
template
class…

Diz
- 1
0
votes
0 answers
overloaded function in derived class
I want to have some overloaded functions in the derived class, but it does not work.
What is the reason? and how to make it work?
#include
struct A {};
struct Compare {
template bool operator()(const T& a, const T& b) const…

pepero
- 7,095
- 7
- 41
- 72
0
votes
2 answers
Function template specialization in C++, no Instance of overloaded function
I'm learning about function template specialization in C++ and am tasked with writing a template function called plus that returns the sum of it's two arguments which maybe of different types. One version that accepts by value and another by…

Mutating Algorithm
- 2,604
- 2
- 29
- 66
0
votes
3 answers
How to deduce template argument for lambda, in function overload?
How should I modify my present function signature
template
bool isPrime(const TypeData& n,TypeFunc1 calcSqrt = {},TypeFunc2 isDivisible = [](const TypeData& a,const TypeData& b)…

Supreeto
- 198
- 9
0
votes
0 answers
How to only enable template function for specified types / disable for any other types
//my_utils.h
namespace A {
namespace B {
template
T encode( U value ) = delete;
template
U decode( T value ) = delete;
uint8_t encode( bool value );
bool decode( uint8_t value );
…

Attila Horvath
- 344
- 5
- 15
0
votes
1 answer
Correct way to overload the multiplication operator in C++ (both directions)
I managed to understand how to implement the overloaded operator as a member function. This way considers the object (instance) is always passed rhs to the operator. In order to get it working, I defined my overloaded operator outside the class. It…

Al-Farouq
- 5
- 3
0
votes
3 answers
Overload function template using a templated type
I have a given function like this:
template
T function(const F& f) const;
This function has various overloads, some of them concept based. Similar to the following:
template
T function(const F&…

Silicomancer
- 8,604
- 10
- 63
- 130
0
votes
0 answers
Trying to extend a class to overwrite a function PHP
Ok, I have the parent class from a plugin I'm trying to extend:
class OsBookingHelper {
public static function get_statuses_list(){
return array( LATEPOINT_BOOKING_STATUS_APPROVED => __('Approved', 'latepoint'),
…