On 2026-08-24 14:19, Jonathan Grant via Std-Proposals wrote:
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?


You mean wrapping the redactee in a template?
I think it will be a less savory pill to swallow, assume the redactee is a function argument:
int munge(MyType raw);

with templates the function signature has to change to:
int munge(Redactable<MyType> raw);

Callers of that function then would have to update their code to support redacting :-(