aboutsummaryrefslogtreecommitdiff
path: root/doc/developer-notes.md
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-22 15:21:11 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-22 15:25:51 +0200
commit52a797bfe5ced4329f2272be417c35730ec8839f (patch)
treedc756fcd89b389f59b0d1408a0226852191b7312 /doc/developer-notes.md
parentc44e734dca64a15fae92255a5d848c04adaad2fa (diff)
downloadbitcoin-52a797bfe5ced4329f2272be417c35730ec8839f.tar.xz
doc: Avoid ADL for function calls
Diffstat (limited to 'doc/developer-notes.md')
-rw-r--r--doc/developer-notes.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md
index bfb64093e1..4cee70863b 100644
--- a/doc/developer-notes.md
+++ b/doc/developer-notes.md
@@ -105,6 +105,28 @@ code.
- `nullptr` is preferred over `NULL` or `(void*)0`.
- `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
+For function calls a namespace should be specified explicitly, unless such functions have been declared within it.
+Otherwise, [argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl), also known as ADL, could be
+triggered that makes code harder to maintain and reason about:
+```c++
+#include <filesystem>
+
+namespace fs {
+class path : public std::filesystem::path
+{
+};
+// The intention is to disallow this function.
+bool exists(const fs::path& p) = delete;
+} // namespace fs
+
+int main()
+{
+ //fs::path p; // error
+ std::filesystem::path p; // compiled
+ exists(p); // ADL being used for unqualified name lookup
+}
+```
+
Block style example:
```c++
int g_count = 0;