Skip to main content
1 vote
1 answer
130 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-...
La Creatura's user avatar
15 votes
1 answer
698 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 ...
Remy Lebeau's user avatar
1 vote
1 answer
138 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&...
Kaiyakha's user avatar
  • 2,073
0 votes
0 answers
50 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 ...
v.oddou's user avatar
  • 6,867
6 votes
3 answers
159 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 ...
Igor G's user avatar
  • 2,668
6 votes
1 answer
151 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 ...
Oersted's user avatar
  • 3,479
5 votes
1 answer
196 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 <...
Fedor's user avatar
  • 24.1k
2 votes
1 answer
121 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 ...
John Grzegorczyk's user avatar
4 votes
2 answers
101 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 ...
Tomer Aberbach's user avatar
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<...
Andrew Carter's user avatar
1 vote
1 answer
62 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 ...
Joe's user avatar
  • 7,166
3 votes
1 answer
156 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&...
Ship's user avatar
  • 31
4 votes
1 answer
74 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 ...
glades's user avatar
  • 5,344
2 votes
2 answers
134 views

Simple string.Split failing with StringSplitOptions.TrimEntries

This returns an array with only one element and thus throws an exception. But it works when I omit StringSplitOptions.TrimEntries. using System; public class Program { public ...
codymanix's user avatar
  • 29.6k
6 votes
1 answer
103 views

Do template parameter packs affect overload resolution?

Look at this code (godbolt): template <typename ...T> void func(const char *it, T &&...t) {} template <typename A, typename B> void func(A &&a, B &&b) {} int main(...
geza's user avatar
  • 30.5k

15 30 50 per page
1
2 3 4 5
54