doc: explain type requirements for post()

Currently, the user learns that `SharedPV::post()` requires the posted
value to be created from the same type instance as the value given to
`SharedPV::open()` only when they try to do it differently and are
presented with an error message. This is an attempt to document this
requirement.
This commit is contained in:
Jure Varlec
2026-02-27 08:14:29 +00:00
committed by mdavidsaver
co-authored by mdavidsaver
parent 525c711ee5
commit bf51e44b7b
2 changed files with 14 additions and 1 deletions
+7
View File
@@ -100,6 +100,13 @@ int main(int argc, char* argv[])
uint32_t count = 0u;
while(!done.wait(delay)) {
// The value that will be given to post() must come from the same type
// _instance_ as the initial value used when calling open(). In other
// words, doing
// auto val = nt::NTScalar{TypeCode::UInt32}.create();
// won't work because it creates a different NTScalar instance. Either
// keep reusing the same Value, clone the existing Value, or keep aroud
// the type instance and create values from there.
auto val = initial.cloneEmpty();
val["value"] = count++;