Hi,
By default the Problem object takes ownership of the cost and loss functions, and uses user-counter approach to allow multiple residual blocks to re-use the same cost/loss function. So if you plan to reuse loss functions within the same Problem you should be able to just do it.
If you plan to use loss function across multiple Problem objects, then you'd need to set Problem::Options::loss_function_ownership to DO_NOT_TAKE_OWNERSHIP, and take care of destructing the loss function when no Problem objects refer to them.