File tree Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -24,3 +24,6 @@ add_executable(adl_nonfunc adl_nonfunc.cpp)
24
24
25
25
add_executable (adl_shutdown adl_shutdown.cpp )
26
26
# Compile only
27
+
28
+ add_executable (adl_niebloid adl_niebloid.cpp )
29
+ # Compile only
Original file line number Diff line number Diff line change
1
+ #include < utility>
2
+
3
+ #include " adl_niebloid_code.h"
4
+ int main () {
5
+ calling_site ();
6
+ }
Original file line number Diff line number Diff line change
1
+ namespace dflt {
2
+ namespace impl {
3
+ template <typename T>
4
+ concept HasCustomImpl = requires (T a) { do_something (a); };
5
+
6
+ struct DoSomethingFn {
7
+ template <typename T> void operator ()(T&& arg) const
8
+ requires HasCustomImpl<T> { do_something (std::forward<T>(arg)); }
9
+ template <typename T> void operator ()(T&&) const
10
+ requires (!HasCustomImpl<T>) { /* default implementation */ }
11
+ };
12
+ }
13
+
14
+ inline namespace var {
15
+ constexpr inline auto do_something = impl::DoSomethingFn{};
16
+ }
17
+ }
18
+
19
+ namespace custom {
20
+ struct X { friend void do_something (const X&){}; };
21
+ struct Y {};
22
+ }
23
+
24
+ void calling_site () {
25
+ custom::X x;
26
+ custom::Y y;
27
+ dflt::do_something (x); // calls custom::do_something(const X&)
28
+ dflt::do_something (y); // calls default implementation
29
+ }
Original file line number Diff line number Diff line change @@ -9,5 +9,5 @@ constexpr inline auto some_func = [](const auto&) {};
9
9
void calling_site () {
10
10
Custom::X x;
11
11
some_func (x); // calls ::some_func
12
- // Because ::some_func prevents ADL , Custom::some_func cannot be called.
12
+ // Because ADL is skipped , Custom::some_func cannot be called.
13
13
}
You can’t perform that action at this time.
0 commit comments