Skip to content

Commit 608397d

Browse files
committed
Example of non-function symbol.
1 parent 8c6fd0d commit 608397d

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

code_examples/theory/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ add_executable(adl_unqalified adl_unqalified.cpp)
1818

1919
add_executable(adl_simple adl_simple.cpp)
2020
# Compile only
21+
22+
add_executable(adl_nonfunc adl_nonfunc.cpp)
23+
# Compile only

code_examples/theory/adl_nonfunc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "adl_nonfunc_code.h"
2+
3+
int main() {
4+
calling_site();
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Custom {
2+
struct X {};
3+
4+
constexpr inline auto some_func = [](const X&) {};
5+
}
6+
7+
void calling_site() {
8+
Custom::X x;
9+
// some_func(x); // Will not compile, not visible to ADL.
10+
Custom::some_func(x); // OK
11+
}

code_examples/theory/adl_unqalified_code.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ void some_call(double) {}
77
void calling_site() {
88
some_call(1); // A::B::some_call
99
some_call(2.0); // A::B::some_call
10-
//some_call("hello world"); Will not compile, no conversion from const char* -> double
10+
// some_call("hello world"); will not compile
11+
// no conversion from const char* -> double
1112
}
1213
}
1314
}

0 commit comments

Comments
 (0)