The options are called :h 'breakindent' and :h 'breakindentopt'. For example
let [&l:bri, &l:briopt] = [v:true, 'shift:'..shiftwidth()]
Note that all "linebreak"-related spaces are purely virtual. They are never written into a file.
@dedoswdi's answer was extremely helpful!
I adapted it somewhat to produce the result for each line on the buffer. My adapted script can be found in this Gist.
After applying it to the original C++ code, I got the results with both cinoptions= (none of them set) and cinoptions=N-s (which triggers the odd behavior with the second struct.)
Here are the ...
" tell which cinoption take effect for current line
com! WhichCinoption call s:which_cinoption()
function s:which_cinoption() abort
" test if cindent take effect
echo "'indentexpr' exists, it overrides 'cindent'."
echo "'cindent' is currently disabled."
This is :h cino-+.
It looks like get_c_indent() (from src/cindent.c) doesn't know about template and treats it like an ordinary expression split over several lines (here namespace serves as "a function" from :h cino-+).
The relevant piece of code from src/cindent.c is
2831 else if (lookfor == LOOKFOR_UNTERM)
2833 if (cont_amount > 0)
In the absence of a complete solution, I thought I'd just write a quick answer that shows one way you can achieve the first part of your question.
Try the following mapping (for F3):
nnoremap <F3> :s/%>%/&\r/g<CR>V``j=gv>>
How it works
Splitting the line
First, it breaks the line on the pipes: