From 291f60f03604a33801b795e34340752824545a66 Mon Sep 17 00:00:00 2001 From: Joey Liaw <26446+jl@users.noreply.github.com> Date: Sat, 5 Jul 2025 23:44:00 -0700 Subject: [PATCH] Fix cpp.md Verifier example compile error This change fixes the following compilation error which would result from the example code for using Verifier: error: non-const lvalue reference to type 'VerifierTemplate<...>' cannot bind to a temporary of type 'VerifierTemplate<...>' --- docs/source/languages/cpp.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/languages/cpp.md b/docs/source/languages/cpp.md index e44e34bbf1b..796be611aed 100644 --- a/docs/source/languages/cpp.md +++ b/docs/source/languages/cpp.md @@ -419,14 +419,15 @@ Each root type will have a verification function generated for it, e.g. for `Monster`, you can call: ```cpp - bool ok = VerifyMonsterBuffer(Verifier(buf, len)); + Verifier verifier(buf, len); + bool ok = VerifyMonsterBuffer(verifier); ``` if `ok` is true, the buffer is safe to read. Besides untrusted data, this function may be useful to call in debug -mode, as extra insurance against data being corrupted somewhere along -the way. +mode, or when using file or network-received buffers, as extra insurance +against data being corrupted somewhere along the way. While verifying a buffer isn't "free", it is typically faster than a full traversal (since any scalar data is not actually touched),