Integer to roman number converter
Using Iterator

Rather than building and passing a string around.

std::string fmt_internal(unsigned long long value) const;


Why not use the output iterator directly?

You build a string letter by letter in the order you would output it, then you move that back to the calling function, then you copy the string to a stream (via an iterator). You can bypass the move and the copy by just writing the letters to the iterator.

Output Iterator not passed through:

template &lt;class charT, class OutputIterator = std::ostreambuf_iterator&lt;charT&gt; &gt;
class roman : public std::num_put &lt; char &gt; {
         //        Expecting =&gt;    ^^^^^^  &lt;CharT, OutputIterator&gt;


OR not making it a template class.

class roman : public std::num_put&lt;char&gt; {


Member Types

Your base type defines some member types.

char_type   CharT
iter_type   OutputIt


This is exactly like your class. Usually I would expect you to pull these types from the parent rather than defining them independently ( unless there is a good reason).

So I would have expected:

typedef std::num_put&lt;CharT, OutputIterator&gt;   parent;
typedef parent::char_type  char_type;   
typedef parent::iter_type  iter_type;


Return value

std::copy(s.begin(), s.end(), i);
return i;


Should this not be:

i = std::copy(s.begin(), s.end(), i);
return i;


It still seems to work (even when the stream is std::stringstream), but I am a tiny bit surprised. You are supposed to return the value of the iterator after putting stuff on the stream (not the original value). It seems to work anyway because the iterator changes the state of the object that it is putting stuff into.