804 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
3
answers
199
views
C++ std::span overload resolution
I want to pass a C-style array to a function taking a std::span, but overload resolution chooses to convert the array to bool instead. Is this behavior required by the standard, or is it a compiler ...
3
votes
1
answer
168
views
How does Java resolve method overloading ambiguity when competing methods have parameters with similar depth hierarchy
Here's a very basic program I wrote to test how Java overloading is resolved when an exact match is not found, and what priority is assigned to other matching methods.
import java.io.*;
public class ...
1
vote
1
answer
137
views
Unexpected overload resolution on clang [duplicate]
(I was making an integer class to replace C's stuff, then this hit me. I wanted an overload for pointer arithmetic.)
MSVC and GCC pass without errors or warnings.
Compilation:
g++ -std=c++2c -fsyntax-...
16
votes
1
answer
717
views
How does overload resolution select from multiple prospective destructors?
After seeing this post: If a class has a destructor declared with a requires clause that evaluates to false, why is the class not trivially destructible? I have a separate question, and I haven't ...
1
vote
1
answer
149
views
Partial ordering of overloaded function templates seems to fail, why?
Consider the following example:
#include <iostream>
#include <vector>
template<typename T>
void foo( T && )
{
std::cout << "Common foo!\n";
}
template&...
0
votes
0
answers
60
views
Pass a variadic templated function taking universal references as pointer to a utility
I have a problem with an attempt at factorizing two utility functions, each calling a given "hardcoded" function, into one utility with a functor call instead. Meaning I have a factoring ...
6
votes
3
answers
160
views
Is there a way to rank user-defined conversions between class templates mirror the ranking of conversions of their template arguments?
Consider the following code (live example):
#include <memory>
struct Base {};
struct Middle : public Base {};
struct Derived : public Middle {};
void foo(Base*);
void foo(Middle*);
void ...
6
votes
1
answer
164
views
function selection finding unexpected candidate when using namespaces
This is a follow-up of this question: `requires` expressions and function namespaces
Trying to design an answer I stumbled on this strange behavior:
#include <cstdio>
// dummy default ...
5
votes
1
answer
211
views
Construction from nested brace-enclosed initializer list
I have a working program that compiles successfully in Visual Studio. But trying to port it to GCC/Clang resulted in some compilation errors.
Maximally reduced example is as follows:
#include <...
2
votes
1
answer
130
views
C++ Templated Overload Resolution Fails Where Standard Resolution Wouldn't
There appears to be a discrepancy in how templated function overloads are resolved and how non-templated function overloads are resolved, but there seem to be some cases where it should not make a ...
4
votes
2
answers
104
views
Why does class extending raw type result in overload ambiguity?
Why is method(new ExtendsRaw()) ambiguous in the code below?
public class Main {
private Main() {}
static class Generic<T> {}
@SuppressWarnings("rawtypes")
static ...
1
vote
0
answers
73
views
"Preloading" a partial set of args into a variadic function [duplicate]
Objective
I'm attempting to wrap a variadic function so I can provide an arbitrary set of arguments now and provide the rest later.
Ultimately, I want to be able to do something like this:
template<...
1
vote
1
answer
77
views
Unable to call desired overload of a generated PInvoke function
I'm am testing out the C#/Win32 project so I can call Win32 Setup API functions with automatically generated PInvoke wrappers. I am unable to make my code call the correct overload of one of the ...
3
votes
1
answer
159
views
C++ overloading resolution when passing initializer lists as arguments
can anyone explain why both cases print "plain int"?
#include <iostream>
void f(const int (&)[2])
{std::cout<<"int array"<<std::endl;}
void f(const int&...
4
votes
1
answer
79
views
Store value category of pointed-to object (for later deref)
Ok this might be a bit difficult to explain:
I want to call a function hello that has an overload for either an rvalue or an lvalue ref of type Json. This Json object is converted from a JsonKey using ...