Date: Mon, 24 Aug 2026 13:19:41 +0100
Could check state when calling redact() and unredact() too
template<class T>
class Redactable {
T value_{};
bool redacted_ = false;
public:
void redact()
pre (!redacted_)
{ redacted_ = true; }
void unredact()
pre (redacted_)
{ redacted_ = false; }
operator T&()
pre (!redacted_)
{
return value_;
}
};
On 24/08/2026 13:07, Sebastian Wittmeier via Std-Proposals wrote:
> AW: [std-proposals] Forget forget let's redact
>
> Something like
>
>
>
> template<class T>
> class Redactable {
> T value_{};
> bool redacted_ = false;
>
> public:
> void redact() { redacted_ = true; }
> void unredact() { redacted_ = false; }
>
> operator T&()
> pre (!redacted_)
> {
> return value_;
> }
> };
>
>
>
> With the only magic being good error handing by the compiler or IDE?
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Jens Maurer <jens.maurer_at_[hidden]>
> *Gesendet:* Mo 24.08.2026 04:14
> *Betreff:* Re: [std-proposals] Forget forget let‘s redact
> *An:* std-proposals_at_[hidden];
> *CC:* Sebastian Wittmeier <wittmeier_at_[hidden]>;
>
>
> On 8/24/26 00:04, Sebastian Wittmeier via Std-Proposals wrote:
> > How about solving it as
> >
> > std::redactable<T>
> >
> > similar to std::optional<T>?
> >
> > It could still be a magic (templated) class going beyond the capabilities of pure library solutions.
>
> I'm ok with having standard library functions whose implementations requires
> implementation-defined means.
>
> I'll oppose standard-library looking functions that (for the caller) change
> the way the core language works at the call site.
>
> Jens
>
>
>
template<class T>
class Redactable {
T value_{};
bool redacted_ = false;
public:
void redact()
pre (!redacted_)
{ redacted_ = true; }
void unredact()
pre (redacted_)
{ redacted_ = false; }
operator T&()
pre (!redacted_)
{
return value_;
}
};
On 24/08/2026 13:07, Sebastian Wittmeier via Std-Proposals wrote:
> AW: [std-proposals] Forget forget let's redact
>
> Something like
>
>
>
> template<class T>
> class Redactable {
> T value_{};
> bool redacted_ = false;
>
> public:
> void redact() { redacted_ = true; }
> void unredact() { redacted_ = false; }
>
> operator T&()
> pre (!redacted_)
> {
> return value_;
> }
> };
>
>
>
> With the only magic being good error handing by the compiler or IDE?
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Jens Maurer <jens.maurer_at_[hidden]>
> *Gesendet:* Mo 24.08.2026 04:14
> *Betreff:* Re: [std-proposals] Forget forget let‘s redact
> *An:* std-proposals_at_[hidden];
> *CC:* Sebastian Wittmeier <wittmeier_at_[hidden]>;
>
>
> On 8/24/26 00:04, Sebastian Wittmeier via Std-Proposals wrote:
> > How about solving it as
> >
> > std::redactable<T>
> >
> > similar to std::optional<T>?
> >
> > It could still be a magic (templated) class going beyond the capabilities of pure library solutions.
>
> I'm ok with having standard library functions whose implementations requires
> implementation-defined means.
>
> I'll oppose standard-library looking functions that (for the caller) change
> the way the core language works at the call site.
>
> Jens
>
>
>
Received on 2026-08-24 12:19:48
