[clang] [clang] Update the lifetimebound example with up-to-date expected warning and change the sample code to be a fully working example (PR #113437)

Boaz Brickner via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 00:59:28 PDT 2024


================
@@ -3702,20 +3702,32 @@ user-declared functions. For example:
 
 .. code-block:: c++
 
+    #include <map>
+    #include <string>
+
+    using namespace std::literals;
+
     // Returns m[key] if key is present, or default_value if not.
     template<typename T, typename U>
     const U &get_or_default(const std::map<T, U> &m [[clang::lifetimebound]],
----------------
bricknerb wrote:

I didn't change this one.
However, it makes sense to me since the function returns either a reference to a value in the map or the default value so both could be referred to from the return value.

https://github.com/llvm/llvm-project/pull/113437


More information about the cfe-commits mailing list