Add static_asserts to catch missuse.

These asserts ensure the generic implementations aren't used for cases
where specialisations have been provided, and that the template parameters
won't cause overruns.
Switch from functional boost lib to version in STL