chipsalliance / UHDM

Universal Hardware Data Model. A complete modeling of the IEEE SystemVerilog Object Model with VPI Interface, Elaborator, Serialization, Visitor and Listener. Used as a compiled interchange format in between SystemVerilog tools. Compiles on Linux gcc, Windows msys2-gcc & msvc, OsX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pointers to other things: can they be const ?

hzeller opened this issue · comments

For instance,we have code like this:

    expr* get_right_expr() const { return right_expr_; }

This will return a pointer that allows to modify state, yet we have the method marked const, which indicates that this todes not modify the object ... we can do so however through the backdoor.

So we should make this return a const expr*

    const expr* get_right_expr() const { return right_expr_; }

iff we need writable and non-writable versions, we should do so having the same signature twice with and without const; the compiler will pick the right one in use.

    const expr* get_right_expr() const { return right_expr_; }
    expr* get_right_expr() { return right_expr_; }