Custom validator doesn't allow default_value
<p>I am trying to use a custom validator instead of overloading <code>operator&gt;&gt;</code> to support an enum type in my option parsing. I have done the following:</p>

<pre><code>#include &lt;iostream&gt;

#include &lt;boost/program_options.hpp&gt;

enum class MyEnum
{
    OneThing,
    AnotherThing
};

void validate(boost::any&amp; v, const std::vector&lt;std::string&gt;&amp; values,
              MyEnum*, int)
{
    // parse the enum from values[0]
    std::cout &lt;&lt; "Test" &lt;&lt; std::endl;
    MyEnum enumValue = MyEnum::OneThing;
    v = enumValue;
}

int main(int argc, char*argv[])
{
    namespace po = boost::program_options;

    po::options_description desc("Options");

    //desc.add_options()("myEnum", po::value&lt;MyEnum&gt;(), "MyEnum value"); // works fine
    desc.add_options()("myEnum", po::value&lt;MyEnum&gt;()-&gt;default_value(MyEnum::OneThing), "MyEnum value"); // compiler error: Source type is not streamable

    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    MyEnum myEnum = vm["myEnum"].as&lt;MyEnum&gt;();

    return 0;
}
</code></pre>

<p>This works fine as long as I don't try to set a <code>default_value</code>, but when I do specify a default_value, I get <code>error: static assertion failed: Source type is neither std::ostream able nor std::wostream able</code>. What else do I need (without overloading stream operators, which is the whole point of using a validator as far as I understand) to do to allow a custom type to get a default_value?</p>