Understanding references between input field-related objects and avoiding circular references

Input field object relationship

This flowchart shows the relationships between the input field widget objects and various callbacks.

A x::w::validated_input_field<type> owns a reference to its x::w::input_field widget. For that reason it should not be placed in the x::w::input_field's appdata, this results in a circular reference.

The input field owns references to the x::w::validated_input_field_contents<type>, on_validate() and on_spin() callbacks. This flowchart clarifies why on_spin() callbacks cannot capture the x::w::validated_input_fields, as this creates a circular reference with the x::w::input_field widget.

on_spin() callbacks can capture x::w::validated_input_field_contents<type> without creating a circular reference.