How to write c++ loss such as smooth l1 loss?

#1

How to write c++ loss such as smooth l1 loss?
Any advice will be appreciated, thanks.