Skip to content

Commit

Permalink
Replace call of virtual in CTOR w/ non-virtual
Browse files Browse the repository at this point in the history
Refactors the call of a virtual member function in the CTOR
by adding a private _impl function, which is non-virtual and
which both the CTOR and the original virtual function
delegate to.

Signed-off-by: Charlie Vigue <[email protected]>
  • Loading branch information
cvigue authored and dsommers committed Nov 10, 2023
1 parent 3927b61 commit cc58225
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions openvpn/buffer/bufcomposed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@ class BufferComposed
: bc(bc_arg),
iter(bc.bv.cbegin())
{
next_buffer();
next_buffer_impl();
}

bool iter_defined()
{
return iter != bc.bv.end();
}

virtual void next_buffer() final
virtual void next_buffer() override
{
next_buffer_impl();
}

// Both ctor and next_buffer delegate here
void next_buffer_impl()
{
if (iter_defined())
reset_buf(**iter++);
Expand Down

0 comments on commit cc58225

Please sign in to comment.