Date: Sat, 22 Aug 2026 09:18:38 +0200
2026-08-17 02:12, Henry Skoglund:
> Hi, I reread all replies to my previous "forget" post, I think I'm
> smarter now :-)
> Here's my new take: let's introduce a std::redact() primarily for safety
> reasons:
> void f()
> {
> int a = 42;
> int b = 41;
> b = std::move(a);
> std::redact(a);
> int c = a; // <--- error: a is redacted, cannot be used
> }
If we get std::redact, wouldn't we also want std::unredact to be able to
still clear() variables in a valid but unspecified state?
for(std::string line; std::getline(std::cin, line);) {
vec.push_back(std::move(line));
std::redact(line);
// ... line unusable here ...
std::unredact(line);
line.clear();
}
For ergonomics, I'd prefer an inferface where redact returns
std::remove_reference_t<T>&& like std::move and unredact returns T& so
that one could do:
for(std::string line; std::getline(std::cin, line);) {
vec.push_back(std::redact(line));
// ... line unusable here ...
std::unredact(line).clear();
}
Br,
Ted
> Hi, I reread all replies to my previous "forget" post, I think I'm
> smarter now :-)
> Here's my new take: let's introduce a std::redact() primarily for safety
> reasons:
> void f()
> {
> int a = 42;
> int b = 41;
> b = std::move(a);
> std::redact(a);
> int c = a; // <--- error: a is redacted, cannot be used
> }
If we get std::redact, wouldn't we also want std::unredact to be able to
still clear() variables in a valid but unspecified state?
for(std::string line; std::getline(std::cin, line);) {
vec.push_back(std::move(line));
std::redact(line);
// ... line unusable here ...
std::unredact(line);
line.clear();
}
For ergonomics, I'd prefer an inferface where redact returns
std::remove_reference_t<T>&& like std::move and unredact returns T& so
that one could do:
for(std::string line; std::getline(std::cin, line);) {
vec.push_back(std::redact(line));
// ... line unusable here ...
std::unredact(line).clear();
}
Br,
Ted
Received on 2026-08-22 07:18:43
