Skip to main content
2 votes
2 answers
147 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
  • 154
1 vote
1 answer
139 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.3k
2 votes
1 answer
76 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
196 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,834
3 votes
2 answers
167 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
246 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
117 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
499 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
128 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
92 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
130 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
0 votes
1 answer
144 views

I'm trying to bring a function into consideration with a using declaration: namespace n { struct S {}; bool equal(S a, S b, std::vector<int> = {1,2}) { return false; } } int main() { ...
ridilculous's user avatar
0 votes
1 answer
85 views

This is a tricky tactic to access a private member of class. But I can't get the point of declaration of friend get inside struct A_member? #include <iostream> struct A { private: int member; ...
Monte's user avatar
  • 49

15 30 50 per page
1
2 3 4 5
26