Skip to main content
-2 votes
0 answers
84 views

I have the following code, where a library defines a few types in the lib namespace including a wrap type template. It also defines the operator+ for the template but checks the operator+ on the ...
Ajay Brahmakshatriya's user avatar
17 votes
1 answer
648 views

Consider struct A; namespace ns { int f(A&&); } struct A { friend int ns::f(A&&); }; int x = f(A{}); GCC trunk translates the last line into a call to ns::f(A&&) in C++20 ...
cpplearner's user avatar
  • 19.9k
2 votes
2 answers
158 views

Following code snippet is taken from this presentation. It can be seen at 31:00. I couldn't understand the reason of ambiguity in this situation. Function 3 can be reachable via ADL naturally but why ...
NB_1907's user avatar
  • 162
1 vote
1 answer
142 views

All this time, I thought that the global namespace resolution operator was optional, and for instances where a symbol refers to something in the global namespace, eg: void my_func() {} int main() { ...
Zebrafish's user avatar
  • 16.6k
2 votes
1 answer
77 views

I have a module A exporting a class template, that uses an overloaded function foo() dependent on the template's type argument: module; export module A; export void foo(bool a) {} export void foo(int ...
Smilediver's user avatar
  • 1,880
2 votes
1 answer
198 views

When you have a default implementation for some function and want to let users provide their own version for custom types, you have to do something like this: #include <cstdio> namespace Lib { ...
Oersted's user avatar
  • 3,914
3 votes
2 answers
169 views

I need to support a new type (OuterType) for libpqxx. This type is located in namespace partner, also namespace contains free function to_string(const OuterType&), which returns wrapper around ...
ValFF's user avatar
  • 35
9 votes
1 answer
251 views

A cpp file and two headers ended up forming this "problematic" translation unit:² namespace na { struct Foo { friend int getFoo(Foo const&, int const&) { return 1; } }...
Enlico's user avatar
  • 30.3k
5 votes
3 answers
139 views

We have dozens of string-like classes spread across dozens of namespaces, but they each have a similar structure: namespace N::N1 { struct S1 { std::string_view sv() const; }; } We'd like to ...
Greg's user avatar
  • 473
3 votes
1 answer
121 views

This is a follow-up to no match for operator<<(std::ostream, ns::Type) when in the global namespace, combined with the namespace numerical_chars trick from https://stackoverflow.com/a/21389821/...
jozxyqk's user avatar
  • 17.7k
10 votes
1 answer
506 views

What (I think) I need How can I define a type trait that checks whether, for a type T, the function ::foo(T) is declared? What I'm finding hard, is to have ::foo in SFINAE friendly way. For instance, ...
Enlico's user avatar
  • 30.3k
0 votes
0 answers
40 views

Why wouldn't ADL kick in when I use unqualified swap() function with std::size_t passed arguments type? For example, I'd expect this to work: std::size_t v1, v2; swap(v1, v2); But it does not. On my ...
Kobi's user avatar
  • 898
4 votes
1 answer
129 views

I'm trying out templates and concepts in C++. I wrote the following code. #include <iostream> #include <string> template <typename T> concept Printable = requires(T a) { { ...
Lipid L's user avatar
  • 43
4 votes
2 answers
95 views

My code: template <typename T> void func(T v) { func2(v); } struct S {}; void func2(int) {} void func2(S) {} int main() { func(1); // error here func(S{}); // OK } ...
user1166's user avatar
  • 129
0 votes
0 answers
132 views

I am trying to have some fun with friend injection and requires clause but I got some trouble : template<int X> struct MaximumValue{}; template<int X> auto injectMaximumValue(MaximumValue&...
Antoine Morrier's user avatar

15 30 50 per page
1
2 3 4 5
27