It might be better (more general) to have a template method that uses boost::range, rather than encode support for specific types.  As you point out, that will lead to duplication of code.